List of utility methods to do HTTP Port Find
int | findFreePort() See https://gist.github.com/vorburger/3429822 Returns a free port number on localhost. ServerSocket socket = null; try { socket = new ServerSocket(0); socket.setReuseAddress(true); int port = socket.getLocalPort(); try { socket.close(); } catch (IOException e) { ... |
int | findFreePort() Find a free port for communication with Prolog. ServerSocket ss = new ServerSocket(0); int port = ss.getLocalPort(); ss.close(); return port; |
int | findFreePort() This is really only used for unit tests but is included in the library so it can be reused across modules. ServerSocket server; try { server = new ServerSocket(0); int port = server.getLocalPort(); ourPorts.add(port); server.close(); Thread.sleep(500); return port; ... |
int | findFreePort() find Free Port ServerSocket socket = new ServerSocket(0); try { return socket.getLocalPort(); } finally { try { socket.close(); } catch (IOException e) { |
ServerSocket | findFreePort() find Free Port ServerSocket server = null; try { server = new ServerSocket(0, 1000, InetAddress.getLocalHost()); server.setReuseAddress(true); } catch (IOException e) { e.printStackTrace(); return server; ... |
int | findFreePort() Returns a free TCP/IP port number on localhost. try (final ServerSocket socket = new ServerSocket(0)) { socket.setReuseAddress(true); return socket.getLocalPort(); } catch (final IOException ex) { throw new IllegalStateException("Could not find a free TCP/IP port", ex); |
int | findFreePort() Attempts to find a free port return findFreePort(DEFAULT_PORT);
|
int | findFreePort() Find free unused TCP port. try (ServerSocket socket = new ServerSocket(0)) { return socket.getLocalPort(); } catch (IOException e) { return -1; |
int | findFreePort(int start, int len) Search for a free TCP and UDP port in the given range int port = start; int end = (len == 0) ? 65535 : start + len; if (end > 65535) end = 65535; while (port < end) { try { ServerSocket socket = new ServerSocket(port); socket.close(); ... |
int | findFreePort(int start, int limit) find Free Port if (start == 0) { return 0; int found = 0; int port = start; int finish = start + limit; while (found == 0 && port < finish) { if (isPortAvailable(port)) { ... |