Class: Coolio::TCPListener
- Defined in:
- lib/cool.io/listener.rb
Instance Method Summary collapse
-
#initialize(addr, port = nil, options = {}) ⇒ TCPListener
constructor
Create a new Coolio::TCPListener on the specified address and port.
Methods inherited from Listener
#close, #fileno, #listen, #on_connection
Methods inherited from IOWatcher
#attach, #detach, #disable, #enable, #on_readable, #on_writable
Methods included from Meta
#event_callback, #watcher_delegate
Methods inherited from Watcher
#attach, #attached?, #detach, #disable, #enable, #enabled?, #evloop
Constructor Details
#initialize(addr, port = nil, options = {}) ⇒ TCPListener
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.
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/cool.io/listener.rb', line 84 def initialize(addr, port = nil, = {}) BasicSocket.do_not_reverse_lookup = true unless [:reverse_lookup] [: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([:backlog]) } super(listen_socket) end |