Java Utililty Methods HTTP Port

List of utility methods to do HTTP Port

Description

The list of methods to do HTTP Port are organized into topic(s).

Method

booleancheckHostAvailability(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;
booleancheckHostPort(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;
...
booleancheckIfPortAvailable(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;
...
ServerSocketcreate(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");
URIcreate(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) {
...
ProxycreateProxy(final Proxy.Type type, final String host, final int port)
create Proxy
return new Proxy(type, InetSocketAddress.createUnresolved(host, port));
DatagramSocketcreateServer(final String host, final int port)
create Server
return new DatagramSocket(new InetSocketAddress(host, port));