code: protected ServerSocket getServerSocket() throws SFException
    {
      try
      {
        return new ServerSocket(
            0, // free port
            0, // default number of connections
            InetAddress.getByName("localhost"));
      }
      catch (IOException ex)
      {
        throw new SFException(ex, ErrorCode.NETWORK_ERROR, ex.getMessage());
      }
    }
docs: Gets a free port on localhost
  
  @return port number
  @throws SFException raised if an error occurs.