Java HTTP Port Find isActivePort(int port)

Here you can find the source of isActivePort(int port)

Description

is Active Port

License

Open Source License

Declaration

public static boolean isActivePort(int port) 

Method Source Code

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

import java.io.IOException;
import java.net.ConnectException;
import java.net.InetAddress;

import java.net.Socket;

public class Main {
    public static boolean isActivePort(int port) {
        Socket socket = null;/*from   w  w  w .jav  a 2 s.c om*/

        boolean var3;
        try {
            InetAddress localAddress = InetAddress.getLocalHost();
            socket = new Socket(localAddress, port);
            return true;
        } catch (ConnectException var20) {
            var3 = false;
        } catch (IOException var21) {
            return true;
        } finally {
            if (null != socket && socket.isConnected()) {
                try {
                    socket.close();
                } catch (IOException var18) {
                    ;
                } catch (Exception var19) {
                    ;
                }
            }

        }

        return var3;
    }
}

Related

  1. getUnusedPorts(final int count, final int start)
  2. getValidZooKeeperPort()
  3. getWsdlLocation(String portPrefix)
  4. getXmlReport(String fileName)
  5. hasPermissionToBindPort(int port)
  6. isAlive(String hostname, int port, int retries)
  7. isAvailablePort(int port)
  8. isBindable(int port)
  9. isBindedPort(String host, int port)