class Coolio::TCPServer

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. Optionally, it can also take any existing core TCPServer object as host and create a Coolio::TCPServer out of it.

Public Class Methods

new(host, port = nil, klass = TCPSocket, *args, &block) click to toggle source
Calls superclass method Coolio::Server.new
# File lib/cool.io/server.rb, line 52
def initialize(host, port = nil, klass = TCPSocket, *args, &block)
  listen_socket = if ::TCPServer === host
    host
  else
    raise ArgumentError, "port must be an integer" if nil == port
    ::TCPServer.new(host, port)
  end
  listen_socket.instance_eval { listen(DEFAULT_BACKLOG) } # Change listen backlog to 1024
  super(listen_socket, klass, *args, &block)
end