Class: Rev::TCPServer

Inherits:
Server show all
Defined in:
lib/rev/server.rb

Overview

TCP server class. Listens on the specified host and port and creates new connection objects of the given class. This is the most common server class. Note that the new connection objects will be bound by default to the same event loop that the server is attached to.

Instance Method Summary collapse

Methods inherited from Listener

#close, #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(host, port, klass = TCPSocket, *args, &block) ⇒ TCPServer

Returns a new instance of TCPServer.



45
46
47
48
49
# File 'lib/rev/server.rb', line 45

def initialize(host, port, klass = TCPSocket, *args, &block)
  listen_socket = ::TCPServer.new(host, port)
  listen_socket.instance_eval { listen(1024) } # Change listen backlog to 1024
  super(listen_socket, klass, *args, &block)
end