List of utility methods to do HTTP Port Find
boolean | isPortAvailable(String host, int port) Is the specified port available? try { (new Socket(host, port)).close(); return true; } catch (IOException e) { return false; |
boolean | isPortAvailable(String host, int port) is Port Available if (host != null) { try { new ServerSocket(port, 50, InetAddress.getByName(host)).close(); return true; } catch (Exception e) { } else { try { ... |
boolean | isPortAvailable(String hostname, int port) Checks whether the supplied port is available on the specified address. ServerSocket socket; try { socket = new ServerSocket(); } catch (IOException e) { throw new IllegalStateException("Unable to create ServerSocket.", e); try { InetSocketAddress sa = new InetSocketAddress(hostname, port); ... |
boolean | isPortAvailable(String hostname, int port) Checks to see if a port/hostname combo is available through opening a socked and closing it again if (port == -1) return false; try { ServerSocket socket = new ServerSocket(); socket.bind(hostname == null || hostname.length() == 0 ? new InetSocketAddress(port) : new InetSocketAddress(hostname, port)); socket.close(); return true; ... |
boolean | isPortAvailable(String hostName, int port) is Port Available InetSocketAddress socketAddress = null; if (hostName == null || "".equals(hostName) || "*".equals(hostName)) { socketAddress = new InetSocketAddress(port); } else { socketAddress = new InetSocketAddress(hostName, port); ServerSocket serverSocket = null; try { ... |
boolean | isPortAvailable(String portNumber) Function to check if a port is available final int port = Integer.parseInt(portNumber); ServerSocket ss = null; try { ss = new ServerSocket(port); ss.setReuseAddress(true); return true; } catch (IOException e) { } finally { ... |
boolean | isPortBound(int port) is Port Bound try (ServerSocket socket = new ServerSocket(port)) { socket.getClass(); return false; } catch (IOException ex) { return true; |
boolean | isPortFree(int port) is Port Free try { Socket socket = new Socket("localhost", port); socket.close(); return false; } catch (ConnectException e) { return true; } catch (SocketException e) { if (e.getMessage().equals("Connection reset by peer")) { ... |
boolean | isPortFree(int port) Check and log is a given port is available boolean portIsFree = true; ServerSocket server = null; try { server = new ServerSocket(port); } catch (IOException e) { portIsFree = false; } finally { if (server != null) { ... |
boolean | isPortFree(int portNumber) Checks to see if the port is available. try { Socket echoSocket = new Socket("localhost", portNumber); echoSocket.close(); return false; } catch (UnknownHostException e) { return true; } catch (IOException e) { return true; ... |