List of utility methods to do HTTP Port Find
int | getNextAvailablePort(final int min, final int max, final Collection get Next Available Port int port = -1; ServerSocket s = null; for (int i = min; i <= max; i++) { try { s = create(new int[] { i }); port = s.getLocalPort(); if (excepted == null || !excepted.contains(port)) { break; ... |
int | getNextAvailablePort(int port) get Next Available Port int offset = detectPortOffset(port); if (offset < 0) { return port; return port + offset; |
String | getNodeName(final String managementServerHostName, final int managementPort) get Node Name final String nodeName = getNodeName(); if (nodeName == null) { throw new IllegalStateException("jboss.node.name could not be determined"); return nodeName; |
int | getNonPrivilegedPort() assigns a port from the range of test ports return getNextNonPrivilegedPort();
|
int | getOpenPort() Get a random open port ServerSocket socket = null; try { socket = new ServerSocket(0); return socket.getLocalPort(); } finally { if (socket != null) { socket.close(); |
int | getPort(final int suggestedPort) Return an open port on current machine. ServerSocket openSocket; try { openSocket = new ServerSocket(suggestedPort); } catch (BindException ex) { openSocket = new ServerSocket(0); final int port = openSocket.getLocalPort(); openSocket.close(); ... |
int | getPort(int port) This method checks whether supplied port is free. ServerSocket socket = null; try { socket = new ServerSocket(port); return socket.getLocalPort(); } finally { if (socket != null) { try { socket.close(); ... |
int | getPort(Proxy proxy) get Port InetSocketAddress address = (InetSocketAddress) proxy.address();
return address.getPort();
|
int | getPort(String endpoint) get port fragment from an endpoint int port = 0; try { URI uri = new URI(endpoint); port = uri.getPort(); } catch (Exception e) { port = 0; return port; ... |
int | getPort(String hostAndPort) get Port return Integer.parseInt(hostAndPort.split(":")[1]); |