List of utility methods to do HTTP Port Find
boolean | available(final int port) available ServerSocket serverSocket = null; try { serverSocket = new ServerSocket(port); serverSocket.setReuseAddress(true); return true; } catch (final IOException e) { } finally { if (serverSocket != null) { ... |
boolean | available(int port) Checks to see if a specific port is available(Bind is not called). ServerSocket ss = null; DatagramSocket ds = null; try { ss = new ServerSocket(port); ss.setReuseAddress(true); ds = new DatagramSocket(port); ds.setReuseAddress(true); return true; ... |
boolean | available(int port) Checks if a port is available by attempting to create a socket try { Socket ignored = new Socket("localhost", port); ignored.close(); return false; } catch (IOException ignored) { return true; |
boolean | available(int port) available Socket s = null; try { s = new Socket("localhost", port); return false; } catch (IOException e) { return true; } finally { if (s != null) { ... |
boolean | available(int port) available if (port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER) { throw new IllegalArgumentException("Invalid start port: " + port); ServerSocket ss = null; DatagramSocket ds = null; try { ss = new ServerSocket(port); ss.setReuseAddress(true); ... |
int | available_port() availablport return available_port(0);
|
ServerSocket | availableAndReturn(int MIN_PORT_NUMBER, int MAX_PORT_NUMBER) available And Return boolean bindSuccess = false; ServerSocket ss = null; AtomicInteger start = new AtomicInteger(MIN_PORT_NUMBER); while (!bindSuccess && start.get() < MAX_PORT_NUMBER) { try { ss = new ServerSocket(start.get()); ss.setReuseAddress(true); bindSuccess = true; ... |
int | availablePort() Will determine the available port ServerSocket s = null; try { s = new ServerSocket(0); s.setReuseAddress(true); return s.getLocalPort(); } catch (Exception e) { throw new IllegalStateException("Failed to discover available port.", e); } finally { ... |
boolean | availablePort(int port) From: https://stackoverflow.com/questions/434718/sockets-discover-port-availability-using-java ServerSocket ss = null; DatagramSocket ds = null; try { ss = new ServerSocket(port); ss.setReuseAddress(true); ds = new DatagramSocket(port); ds.setReuseAddress(true); return true; ... |
boolean | availablePort(int pPort) Method that checks whether or not a port is available on the host computer. ServerSocket newlySocket = null; boolean response = false; try { newlySocket = new ServerSocket(pPort); response = true; } catch (IOException e) { response = false; } finally { ... |