class Coolio::TCPListener

Public Class Methods

new(addr, port = nil, options = {}) click to toggle source

Create a new Coolio::TCPListener on the specified address and port. Accepts the following options:

:backlog - Max size of the pending connection queue (default 1024)
:reverse_lookup - Retain BasicSocket's reverse DNS functionality (default false)

If the specified address is an TCPServer object, it will ignore the port and :backlog option and create a new Coolio::TCPListener out of the existing TCPServer object.

Calls superclass method Coolio::Listener.new
# File lib/cool.io/listener.rb, line 84
def initialize(addr, port = nil, options = {})
  BasicSocket.do_not_reverse_lookup = true unless options[:reverse_lookup]
  options[:backlog] ||= DEFAULT_BACKLOG

  listen_socket = if ::TCPServer === addr
    addr
  else
    raise ArgumentError, "port must be an integer" if nil == port
    ::TCPServer.new(addr, port)
  end
  listen_socket.instance_eval { listen(options[:backlog]) }
  super(listen_socket)
end