# File lib/rubytorrent/server.rb, line 34
  def initialize(hostname=nil, port=nil, http_proxy=ENV["http_proxy"])
    @http_proxy = http_proxy
    @server = nil
    if port.nil?
      @port = PORT_RANGE.detect do |p|
        begin
          @server = TCPServer.new(hostname, p)
          @port = p
        rescue Errno::EADDRINUSE
          @server = nil
        end
        !@server.nil?
      end
      raise Errno::EADDRINUSE, "ports #{PORT_RANGE}" unless @port
    else
      @server = TCPServer.new(hostname, port)
      @port = port
    end

    @id = "rubytor" + VERSION.chr + (1 .. 12).map { |x| rand(256).chr }.join
    @controllers = {}
  end