Java HTTP Port Find isPortInUse(final String host, final Integer port)

Here you can find the source of isPortInUse(final String host, final Integer port)

Description

is Port In Use

License

Open Source License

Declaration

public static final synchronized Boolean isPortInUse(final String host, final Integer port) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.net.Socket;

public class Main {
    public static final synchronized Boolean isPortInUse(final String host, final Integer port) {
        Boolean result = false;/*  www . j a v a2 s .c om*/
        try {
            (new Socket(host, port)).close();
            result = true;
        } catch (IOException ex) {
        }
        return result;
    }
}

Related

  1. isPortFree(int port)
  2. isPortFree(int port)
  3. isPortFree(int portNumber)
  4. isPortFree(String hostName, String port)
  5. isPortFreeClient(String hostName, int portNumber)
  6. isPortInUse(int port)
  7. isPortOnUse(int port)
  8. isPortOpen(int port)
  9. isPortOpen(int port, String host)