package lc.mecha.net;

import java.io.IOException;
import java.net.ServerSocket;

public class NetworkPortUtils {
    /**
     * Find an available free port on the local machine.
     */
    public static int findFreePort() throws IOException {
        try (ServerSocket socket = new ServerSocket(0)) {
            socket.setReuseAddress(true);
            return socket.getLocalPort();
        }
    }
}
