List of utility methods to do HTTP Port Find
int | getFreePort() Returns the next available port number on the local host. ServerSocket socket = null; try { socket = new ServerSocket(0); return socket.getLocalPort(); } catch (IOException e) { } finally { if (socket != null) { try { ... |
int | getFreePort() Get available port. try (ServerSocket socket = new ServerSocket(0)) { return socket.getLocalPort(); } catch (IOException ioe) { return -1; |
int | getFreePort() get Free Port int result; try { ServerSocket socket = new ServerSocket(0); result = socket.getLocalPort(); socket.close(); } catch (IOException ioe) { throw new RuntimeException("Failed to find free port.", ioe); return result; |
int | getFreePort() get Free Port try { try (ServerSocket socket = new ServerSocket(0)) { socket.setReuseAddress(true); return socket.getLocalPort(); } catch (IOException e) { return -1; |
int | getFreePort() Get an arbitrary free port on the localhost for (int port = 22332; port < 22500; port++) { if (trySocket(port)) { return port; throw new IllegalStateException("Cannot find a single free port"); |
int | getFreePort() get Free Port ServerSocket serverSocket = new ServerSocket(0); int port = serverSocket.getLocalPort(); serverSocket.close(); return port; |
int | getFreePort() get Free Port try (ServerSocket s = new ServerSocket(0)) { s.setReuseAddress(true); return s.getLocalPort(); |
int | getFreePort() get Free Port try { final ServerSocket ss = new ServerSocket(0); ss.setReuseAddress(true); final int port = ss.getLocalPort(); ss.close(); return port; } catch (final Throwable t) { throw new RuntimeException(t); ... |
int | getFreePort() tries to get a free port and returns it ServerSocket serverSocket = null; try { serverSocket = new ServerSocket(0); int freePort = serverSocket.getLocalPort(); return freePort; } catch (IOException e) { return -1; } finally { ... |
int | getFreePort() Gets a random free port in the non-privileged range of 1025-65535. return getFreePort(MIN_SAFE_PORT, MAX_PORT);
|