Java HTTP Port Find isAvailablePort(int port)

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

Description

is Available Port

License

Apache License

Declaration

public static boolean isAvailablePort(int port) 

Method Source Code


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

import java.io.IOException;
import java.net.*;

public class Main {
    public static boolean isAvailablePort(int port) {
        ServerSocket ss = null;// w  w w  .java 2  s . c  o m
        try {
            ss = new ServerSocket(port);
            ss.bind(null);
            return true;
        } catch (IOException e) {
            return false;
        } finally {
            if (ss != null) {
                try {
                    ss.close();
                } catch (IOException e) {
                }
            }
        }
    }
}

Related

  1. getWsdlLocation(String portPrefix)
  2. getXmlReport(String fileName)
  3. hasPermissionToBindPort(int port)
  4. isActivePort(int port)
  5. isAlive(String hostname, int port, int retries)
  6. isBindable(int port)
  7. isBindedPort(String host, int port)
  8. isBound(int port)
  9. isBound(int port)