Java HTTP Port Find hasPermissionToBindPort(int port)

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

Description

has Permission To Bind Port

License

Open Source License

Declaration

public static boolean hasPermissionToBindPort(int port) 

Method Source Code

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

import java.net.ServerSocket;

public class Main {
    public static boolean hasPermissionToBindPort(int port) {
        ServerSocket s = null;/* w  w w  .  j a v  a  2 s  .c  o  m*/
        try {
            s = new ServerSocket(port);

            return true;
        } catch (Exception e) {
            return false;
        } finally {
            if (s != null)
                try {
                    s.close();
                } catch (Exception e) {
                }
        }

    }
}

Related

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