List of utility methods to do HTTP Port Find
boolean | isPortAvailable(int port) Check if port is available ServerSocket serverSocket; try { serverSocket = new ServerSocket(); } catch (IOException ex) { throw new IllegalStateException("Unable to create ServerSocket.", ex); try { InetSocketAddress sa = new InetSocketAddress(port); ... |
boolean | isPortAvailable(int port) See if a port is available for listening on by trying to listen on it and seeing if that works or fails. try { ServerSocket socket = new ServerSocket(port); socket.close(); return true; } catch (IOException e) { return false; |
boolean | isPortAvailable(int port) is Port Available ServerSocket ss = null; DatagramSocket ds = null; try { ss = new ServerSocket(port); ss.setReuseAddress(true); ds = new DatagramSocket(port); ds.setReuseAddress(true); return true; ... |
boolean | isPortAvailable(int port) is Port Available try (DatagramSocket udp = new DatagramSocket(port); ServerSocket tcp = new ServerSocket(port)) { tcp.setReuseAddress(true); udp.setReuseAddress(true); return true; } catch (IOException ex) { return false; |
boolean | isPortAvailable(int port) Checks to see if a specific port is 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); ... |
boolean | isPortAvailable(int port) is Port Available if (port < 1 || port > 65535) { throw new IllegalArgumentException("Invalid start port: " + port); try (ServerSocket ss = new ServerSocket(port); DatagramSocket ds = new DatagramSocket(port)) { ss.setReuseAddress(true); ds.setReuseAddress(true); return true; } catch (IOException ignored) { ... |
boolean | isPortAvailable(int port) Checks to see if a specific port is available. ServerSocket ss = null; DatagramSocket ds = null; try { ss = new ServerSocket(port); ss.setReuseAddress(true); ds = new DatagramSocket(port); ds.setReuseAddress(true); return true; ... |
void | isPortAvailable(String host, int port) is Port Available Socket s = new Socket(); s.bind(new InetSocketAddress(host, port)); s.close(); |
boolean | isPortAvailable(String host, int port) See if a port is available for listening on by trying connect to it and seeing if that works or fails try { Socket socket = new Socket(host, port); socket.close(); return false; } catch (IOException e) { return true; |
boolean | isPortAvailable(String host, int port) is Port Available Socket socket = null; boolean available = false; try { socket = new Socket(host, port); available = true; } catch (IOException e) { } finally { if (socket != null) { ... |