code: boolean isFree( int port )
      {
          try
          {
              ServerSocket sock = new ServerSocket( port );
              sock.close();
              // is free:
              return true;
              // We rely on an exception thrown to determine availability or not availability.
          } catch( Exception e )
          {
              // not free.
              return false;
          }
      }
docs: Checks a given port for availability (by creating a temporary socket)
  
  Package visibility to enable overwriting in test.
  
  @param port Port to check
  
  @return true if its free, otherwise false.