Servers listen for incoming connections and create new connection objects whenever incoming connections are received. The default class for new connections is a Socket, but any subclass of IOWatcher is acceptable.
# File lib/cool.io/server.rb, line 12 def initialize(listen_socket, klass = Socket, *args, &block) # Ensure the provided class responds to attach unless klass.allocate.is_a? IO raise ArgumentError, "can't convert #{klass} to Coolio::IO" end # Verify the arity of the provided arguments arity = klass.instance_method(:initialize).arity expected = arity >= 0 ? arity : -(arity + 1) if (arity >= 0 and args.size + 1 != expected) or (arity < 0 and args.size + 1 < expected) raise ArgumentError, "wrong number of arguments for #{klass}#initialize (#{args.size+1} for #{expected})" end @klass, @args, @block = klass, args, block super(listen_socket) end
Generated with the Darkfish Rdoc Generator 2.