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

booleanisPortUsing(String host, int port)
Check if a port is being used in the specified host
boolean flag = false;
try {
    InetAddress theAddress = InetAddress.getByName(host);
    Socket socket = new Socket(theAddress, port);
    flag = true;
} catch (IOException e) {
return flag;
...
booleanisPortUsing(String host, int port)
true:already in using false:not using
boolean flag = false;
InetAddress theAddress = InetAddress.getByName(host);
try {
    Socket socket = new Socket(theAddress, port);
    flag = true;
} catch (IOException e) {
return flag;
...
booleanisReachable(final String hostName, int port, int timeout)
Checks that given hostname is reacheble in certain timeout.
try (Socket socket = new Socket()) {
    socket.connect(new InetSocketAddress(hostName, port), timeout);
    return true;
} catch (IOException ignore) {
    return false;
booleanisReachableByPing(String host, int port)
is Reachable By Ping
Socket ignored = null;
try {
    ignored = new Socket(host, port);
    ignored.close();
    return true;
} catch (IOException e) {
    return false;
booleanisServerListening(String host, int port)
Checks if the server is listening using the host name and the port number specified.
Socket socket = null;
try {
    socket = new Socket(host, port);
    return true;
} catch (Exception e) {
    return false;
} finally {
    if (socket != null) {
...
booleanisServerListening(String host, int port)
is Server Listening
try {
    Socket s = new Socket(host, port);
    return true;
} catch (Exception ex) {
return false;
booleanisServerPortFree(int port)
Check whether the specified server socket port is free or not.
ServerSocket s;
try {
    s = new ServerSocket(port);
    s.close();
} catch (IOException e) {
    return false;
return true;
...
booleanisServing(String host, int port)
is Serving
if (port < 0) {
    return false;
try {
    Socket socket = new Socket(host, port);
    socket.close();
    return true;
} catch (IOException e) {
...
booleanisStart(String host, int port)
is Start
return isStart1(host, port);
booleanisStart0(String host, int port)
is Start
boolean status = false;
Socket socket = null;
try {
    socket = new Socket(host, port);
    status = true;
    socket.close();
} catch (Exception e) {
} finally {
...