List of utility methods to do HTTP Port Find
int | getAvailablePort() get Available Port int port = -1; try { ServerSocket server = new ServerSocket(0); port = server.getLocalPort(); server.close(); } catch (IOException exception) { port = -1; return port; |
int | getAvailablePort() Getting a available port on range 60000:61000 int initialP = 60000; int finalP = 61000; for (int i = initialP; i < finalP; i++) { int port = new Random().nextInt(finalP - initialP) + initialP; ServerSocket ss = null; DatagramSocket ds = null; try { ss = new ServerSocket(port); ... |
int | getAvailablePort() get Available Port ServerSocket ss = null; try { ss = new ServerSocket(); ss.bind(null); return ss.getLocalPort(); } catch (IOException e) { return getRandomPort(); } finally { ... |
int | getAvailablePort() get Available Port ServerSocket ss = null; try { ss = new ServerSocket(); ss.bind(null); return ss.getLocalPort(); } catch (IOException e) { return getRandomPort(); } finally { ... |
int | getAvailablePort() Find a port that is available. try (ServerSocket socket = new ServerSocket(0)) { return socket.getLocalPort(); } catch (IOException e) { throw new IllegalStateException("Cannot find available port: " + e.getMessage(), e); |
int | getAvailablePort() get Available Port ServerSocket serverside = null; int port = 0; try { serverside = new ServerSocket(0); port = serverside.getLocalPort(); } catch (IOException exception) { exception.printStackTrace(); } finally { ... |
int | getAvailablePort() Returns port number which is currently not listened by local services. try (final ServerSocket ss = new ServerSocket(0)) { return ss.getLocalPort(); } catch (final IOException e) { throw new IllegalStateException("Unable to get local port: no ports available"); |
int | getAvailablePort() get Available Port try { try (final ServerSocket serverSocket = new ServerSocket(0)) { return serverSocket.getLocalPort(); } catch (IOException e) { throw new IllegalStateException(e); |
int | getAvailablePort() get Available Port for (int i = 0; i < 50; i++) { ServerSocket serverSocket = null; try { serverSocket = new ServerSocket(0); int port = serverSocket.getLocalPort(); if (port != 0) { return port; } finally { serverSocket.close(); throw new IOException("could not find free port"); |
int | getAvailablePort() get one available port return availablePort(0);
|