         # File lib/eventmachine.rb, line 540
    540:   def self.start_server server, port=nil, handler=nil, *args, &block
    541:     begin
    542:       port = Integer(port)
    543:     rescue ArgumentError, TypeError
    544:       # there was no port, so server must be a unix domain socket
    545:       # the port argument is actually the handler, and the handler is one of the args
    546:       args.unshift handler if handler
    547:       handler = port
    548:       port = nil
    549:     end if port
    550:
    551:     klass = if (handler and handler.is_a?(Class))
    552:       raise ArgumentError, 'must provide module or subclass of EventMachine::Connection' unless Connection > handler
    553:       handler
    554:     else
    555:       Class.new( Connection ) {handler and include handler}
    556:     end
    557:
    558:     arity = klass.instance_method(:initialize).arity
    559:     expected = arity >= 0 ? arity : -(arity + 1)
    560:     if (arity >= 0 and args.size != expected) or (arity < 0 and args.size < expected)
    561:       raise ArgumentError, "wrong number of arguments for #{klass}#initialize (#{args.size} for #{expected})"
    562:     end
    563:
    564:     s = if port
    565:           start_tcp_server server, port
    566:         else
    567:           start_unix_server server
    568:         end
    569:     @acceptors[s] = [klass,args,block]
    570:     s
    571:   end