# File lib/eventmachine.rb, line 902
902:   def self.open_datagram_socket address, port, handler=nil, *args
903:     klass = if (handler and handler.is_a?(Class))
904:       raise ArgumentError, 'must provide module or subclass of EventMachine::Connection' unless Connection > handler
905:       handler
906:     else
907:       Class.new( Connection ) {handler and include handler}
908:     end
909: 
910:     arity = klass.instance_method(:initialize).arity
911:     expected = arity >= 0 ? arity : -(arity + 1)
912:     if (arity >= 0 and args.size != expected) or (arity < 0 and args.size < expected)
913:       raise ArgumentError, "wrong number of arguments for #{klass}#initialize (#{args.size} for #{expected})"
914:     end
915: 
916:     s = open_udp_socket address, port.to_i
917:     c = klass.new s, *args
918:     @conns[s] = c
919:     block_given? and yield c
920:     c
921:   end