         # File lib/eventmachine.rb, line 891
    891:         def self::open_datagram_socket address, port, handler=nil, *args
    892:                 klass = if (handler and handler.is_a?(Class))
    893:                   raise ArgumentError, 'must provide module or subclass of EventMachine::Connection' unless Connection > handler
    894:                         handler
    895:                 else
    896:                         Class.new( Connection ) {handler and include handler}
    897:                 end
    898:
    899:     arity = klass.instance_method(:initialize).arity
    900:     expected = arity >= 0 ? arity : -(arity + 1)
    901:     if (arity >= 0 and args.size != expected) or (arity < 0 and args.size < expected)
    902:       raise ArgumentError, "wrong number of arguments for #{klass}#initialize (#{args.size} for #{expected})"
    903:     end
    904:
    905:                 s = open_udp_socket address, port
    906:                 c = klass.new s, *args
    907:                 @conns[s] = c
    908:                 block_given? and yield c
    909:                 c
    910:         end