List of utility methods to do HTTP Port
boolean | checkHostAvailability(String host, int port) check Host Availability try (Socket s = new Socket(host, port)) { s.getOutputStream().write(0); return true; } catch (IOException ex) { return false; |
boolean | checkHostPort(String connectionString) check Host Port String[] split = connectionString.split(":"); String serverAddress = split[0]; Integer serverPort = Integer.valueOf(split[1]); try (Socket s = new Socket(serverAddress, serverPort)) { return true; } catch (IOException ex) { return false; ... |
boolean | checkIfPortAvailable(int port) check If Port Available ServerSocket tcpSocket = null; DatagramSocket udpSocket = null; try { tcpSocket = new ServerSocket(port); tcpSocket.setReuseAddress(true); udpSocket = new DatagramSocket(port); udpSocket.setReuseAddress(true); return true; ... |
ServerSocket | create(final int[] ports) create for (final int port : ports) { try { return new ServerSocket(port); } catch (final IOException ex) { throw new IOException("No free port found"); |
URI | create(String scheme, String rawUserInfo, String host, int port, String rawPath, String rawQuery, String rawFragment) Returns a hierarchical URI constructed from the given components. StringBuilder sb = new StringBuilder(); if (scheme != null) { sb.append(scheme).append(':'); if (host != null) { sb.append("//"); if (rawUserInfo != null) { ... |
Proxy | createProxy(final Proxy.Type type, final String host, final int port) create Proxy return new Proxy(type, InetSocketAddress.createUnresolved(host, port)); |
DatagramSocket | createServer(final String host, final int port) create Server return new DatagramSocket(new InetSocketAddress(host, port)); |