Sujin Philip created JRUBY-6638:
-----------------------------------

             Summary: Multicast UDPSocket send does not work with host and port
                 Key: JRUBY-6638
                 URL: https://jira.codehaus.org/browse/JRUBY-6638
             Project: JRuby
          Issue Type: Bug
          Components: Standard Library
    Affects Versions: JRuby 1.7
         Environment:  jruby 1.7.0.dev (ruby-1.9.3-p139) (2012-04-30 4e6078d) 
(Java HotSpot(TM) 64-Bit Server VM 1.6.0_26) [linux-amd64-java]
            Reporter: Sujin Philip
            Assignee: Thomas E Enebo


UDPSocket send seems to be working fine without the multicast.

{code}
jruby-head :001 > require 'socket'
 => true 
jruby-head :002 > require 'ipaddr'
 => true 
jruby-head :003 > @multicast_ip = "239.221.222.59"
 => "239.221.222.59" 
jruby-head :004 > @port = 25464
 => 25464 
jruby-head :005 > SOCKET_TIMEOUT = 1
 => 1 
jruby-head :006 >   def create_multicast_socket
jruby-head :007?>       ip = IPAddr.new(@multicast_ip).hton + 
IPAddr.new("0.0.0.0").hton
jruby-head :008?>       socket = UDPSocket.open
jruby-head :009?>       socket.setsockopt(Socket::IPPROTO_IP, 
Socket::IP_MULTICAST_TTL, "\x01\x00\x00\x00")
jruby-head :010?>       socket.setsockopt(Socket::IPPROTO_IP, 
Socket::IP_ADD_MEMBERSHIP, ip)
jruby-head :011?>       socket.setsockopt(Socket::SOL_SOCKET, 
Socket::SO_REUSEADDR, 1)
jruby-head :012?>   
jruby-head :013 >         optval = [SOCKET_TIMEOUT, 0].pack("l_2")
jruby-head :014?>       socket.setsockopt(Socket::SOL_SOCKET, 
Socket::SO_SNDTIMEO, optval)
jruby-head :015?>   
jruby-head :016 >         socket
jruby-head :017?>     end
 => nil 
jruby-head :018 > 
jruby-head :019 >   sender = create_multicast_socket
 => #<UDPSocket:fd 87> 
jruby-head :020 > send
send     sender   
jruby-head :020 > sender.send("Test Data.", 0, @multicast_ip, @port)
Java::JavaLang::NullPointerException: 
        from org.jruby.ext.socket.RubyUDPSocket.send(RubyUDPSocket.java:307)
        from 
org.jruby.ext.socket.RubyUDPSocket$INVOKER$i$send.call(RubyUDPSocket$INVOKER$i$send.gen)
        from 
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:282)
        from 
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:71)
        from org.jruby.ast.CallManyArgsNode.interpret(CallManyArgsNode.java:59)
        from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
        from org.jruby.ast.RootNode.interpret(RootNode.java:129)
        from 
org.jruby.evaluator.ASTInterpreter.INTERPRET_EVAL(ASTInterpreter.java:96)
        from 
org.jruby.evaluator.ASTInterpreter.evalWithBinding(ASTInterpreter.java:167)
        from org.jruby.RubyKernel.evalCommon(RubyKernel.java:1075)
        from org.jruby.RubyKernel.eval19(RubyKernel.java:1037)
        from 
org.jruby.RubyKernel$INVOKER$s$0$3$eval19.call(RubyKernel$INVOKER$s$0$3$eval19.gen)
        from 
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:186)
        from 
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:69)
        from 
org.jruby.ast.FCallManyArgsNode.interpret(FCallManyArgsNode.java:60)
        from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
... 116 levels...
        from 
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
        from 
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:190)
        from 
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:199)
        from 
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:312)
        from 
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:169)
        from 
home.developer.$_dot_rvm.rubies.jruby_minus_head.bin.irb.__file__(/home/developer/.rvm/rubies/jruby-head/bin/irb:17)
        from 
home.developer.$_dot_rvm.rubies.jruby_minus_head.bin.irb.load(/home/developer/.rvm/rubies/jruby-head/bin/irb)
        from org.jruby.Ruby.runScript(Ruby.java:780)
        from org.jruby.Ruby.runScript(Ruby.java:773)
        from org.jruby.Ruby.runNormally(Ruby.java:650)
        from org.jruby.Ruby.runFromMain(Ruby.java:499)
        from org.jruby.Main.doRunFromMain(Main.java:375)
        from org.jruby.Main.internalRun(Main.java:264)
        from org.jruby.Main.run(Main.java:230)
        from org.jruby.Main.run(Main.java:214)
        
{code}

Although there is a work around.
{code}
ruby-head :028 >   sender.connect(@multicast_ip, @port)
 => 0 
jruby-head :029 > sender.send("Test Data.", 0)
 => 10 
jruby-head :030 >
{code}

This behaviour is only seen with multicast sockets.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to