Java Utililty Methods HTTP Port Find

List of utility methods to do HTTP Port Find

Description

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

Method

booleanisLocalPortOccupied(int portNum)
is Local Port Occupied
Socket s = new Socket();
try {
    s.connect(new InetSocketAddress(portNum));
    return s.isConnected();
} catch (Exception e) {
    return false;
} finally {
    try {
...
booleanisLocalPortUsed(int port)
Check if aport is being used in the local host
boolean flag = true;
try {
    flag = isPortUsing("127.0.0.1", port);
} catch (Exception e) {
return flag;
booleanisLoclePortUsing(int port)
true:already in using false:not using
boolean flag = true;
try {
    flag = isPortUsing("127.0.0.1", port);
} catch (Exception e) {
return flag;
booleanisMulticastSupported(NetworkInterface pNif)
Check whether the given interface supports multicast and is up
return pNif != null && checkMethod(pNif, isUp) && checkMethod(pNif, supportsMulticast);
booleanisOpen(final int port)
Port is open.
boolean open;
try {
    new Socket((String) null, port);
    open = true;
} catch (final IOException ex) {
    open = false;
return open;
...
booleanisPortActive(String host, int port)
is Port Active
Socket s = null;
try {
    s = new Socket();
    s.setReuseAddress(true);
    SocketAddress sa = new InetSocketAddress(host, port);
    s.connect(sa, 3000);
    return true;
} catch (IOException e) {
...
booleanisPortAvailable(final int port)
Checks if the specified is available as listen port.
try (ServerSocket tcp = new ServerSocket(port); DatagramSocket udp = new DatagramSocket(port)) {
    return tcp.isBound() && udp.isBound();
} catch (Exception e) { 
    return false;
booleanisPortAvailable(int p)
is Port Available
try {
    ServerSocket test = new ServerSocket(p);
    test.close();
} catch (BindException e) {
    return false;
} catch (IOException e) {
    return false;
return true;
booleanisPortAvailable(int port)
Checks to see if a specific port is available.
if ((port < MIN_PORT_NUMBER) || (port > MAX_PORT_NUMBER))
    return false;
ServerSocket ss = null;
DatagramSocket ds = null;
try {
    ss = new ServerSocket(port);
    ss.setReuseAddress(true);
    ds = new DatagramSocket(port);
...
booleanisPortAvailable(int port)
is Port Available
try {
    Socket s = new Socket("127.0.0.1", port);
    s.close();
    return false;
} catch (Exception ex) {
    return true;