# File lib/eventmachine.rb, line 773
773:         def self::open_datagram_socket address, port, handler=nil, *args
774:                 klass = if (handler and handler.is_a?(Class))
775:                         handler
776:                 else
777:                         Class.new( Connection ) {handler and include handler}
778:                 end
779: 
780:     arity = klass.instance_method(:initialize).arity
781:     expected = arity >= 0 ? arity : -(arity + 1)
782:     if (arity >= 0 and args.size != expected) or (arity < 0 and args.size < expected)
783:       raise ArgumentError, "wrong number of arguments for #{klass}#initialize (#{args.size} for #{expected})"
784:     end
785: 
786:                 s = open_udp_socket address, port
787:                 c = klass.new s, *args
788:                 @conns[s] = c
789:                 block_given? and yield c
790:                 c
791:         end