Java HTTP Port Find isFreeTCPPort(final int port)

Here you can find the source of isFreeTCPPort(final int port)

Description

is Free TCP Port

License

Apache License

Declaration

public static boolean isFreeTCPPort(final int port) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.net.ServerSocket;

public class Main {
    public static boolean isFreeTCPPort(final int port) {
        try {//from  ww w . j  av a2s .  c om
            final ServerSocket ss = new ServerSocket(port);
            ss.setReuseAddress(true);
            ss.close();
            return true;
        } catch (final Throwable t) {
            t.printStackTrace();
            return false;
        }
    }
}

Related

  1. isBindedPort(String host, int port)
  2. isBound(int port)
  3. isBound(int port)
  4. isConnectionAlive(String protocol, String host, int port)
  5. isFreePort(int portNumber)
  6. isHostAvailable(final String host, final int port)
  7. isHostReachable(String host, int port, int connTimeout)
  8. isListening(String host, int port)
  9. isLivereloadAvailable(int port)