static boolean isAvailablePort(InetAddress inetAddress,int port){
  if (port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER) {
    throw new IllegalArgumentException("Invalid port number: " + port);
  }
  Socket socket=null;
  try {
    socket=new Socket(inetAddress,port);
    return false;
  }
 catch (  IOException ignore) {
    return true;
  }
 finally {
    if (socket != null) {
      try {
        socket.close();
      }
 catch (      IOException ignore) {
      }
    }
  }
}

static boolean isAvailablePort ( InetAddress inetAddress , int port ) { if ( port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER ) { throw new IllegalArgumentException ( "Invalid port number: " + port ) ; } Socket socket = null ; try { socket = new Socket ( inetAddress , port ) ; return false ; } catch ( IOException ignore ) { return true ; } finally { if ( socket != null ) { try { socket . close ( ) ; } catch ( IOException ignore ) { } } } }
checks to see if a specific port is available .
