Multicast and windows

report for trying IP multicast with ruby 1.8 / iron ruby / jruby :

sending datagramme :
ok for all
receiving datagramme :
ok for iron ruby, no reception for ruby 1.8, error with jruby

test sending datagramme :

ruby sim.rb s 3302 229.1.1.1 5000

test receiving datagramme :

ruby sim.rb r 3302 229.1.1.1 5000

NOTA

IRON RUBY:
Socket::IP_ADD_MEMBERSHIP = 12 must be done
Socket::IP_MULTICAST_LOOP, Socket::IP_MULTICAST_TTL not known

JRUBY : “can’t convert Fixnum into String” on socket.bind

ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]
IronRuby 0.9.2.0 on .NET 2.0.0.0
jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3)
(Java HotSpot™ Client VM 1.6.0_16) [x86-java]

Regis Siger wrote:

report for trying IP multicast with ruby 1.8 / iron ruby / jruby :

No code?
Were any VM’s successful?
Did you try it with BasicSocket.do_not_reverse_lookup = true?
-r

Roger P. wrote:

Regis Siger wrote:

report for trying IP multicast with ruby 1.8 / iron ruby / jruby :

No code?
Were any VM’s successful?
Did you try it with BasicSocket.do_not_reverse_lookup = true?
-r

code is in sim.rb, attachment of first post

code is in sim.rb, attachment of first post

Have you tried it with linux at all? how does it work there?
-r

Were any VM’s successful?
Did you try it with BasicSocket.do_not_reverse_lookup = true?

Did you try 1.9.1 on doze?
-r

Some other test :
Linux : ok with ruby 1.8 (ubuntu 9.10 and “route add 224.0.0.0…” )

I assume Linux 1.9.x works, too, then?

windows : ruby 1.9.1 : Nok (no receive)
(TCP/IP on ruby 1.9/windows is realy broken !)

What else is broken?
You can report bugs on redmine.ruby-lang.org

jruby 1.4.0 : error on socket.bind

I reported a bug to them.

-r

Some other test :
Linux : ok with ruby 1.8 (ubuntu 9.10 and “route add 224.0.0.0…” )
windows : ruby 1.9.1 : Nok (no receive)
(TCP/IP on ruby 1.9/windows is realy broken !)
jruby 1.4.0 : error on socket.bind

works for me with all versions of ruby on windows… (windows 7).

On Thu, Dec 10, 2009 at 6:50 AM, Regis Aubarede
[email protected] wrote:

jruby 1.4.0 : error on socket.bind

You should definitely try JRuby 1.5.1. There were hundreds of bug
fixes, including many for sockets.

  • Charlie

Roger P. wrote:

Were any VM’s successful?
Did you try it with BasicSocket.do_not_reverse_lookup = true?
yes
Have you tried it with linux at all? how does it work there?
now, yes

Did you try 1.9.1 on doze?
now, yes
-r

Some other test :
Linux : ok with ruby 1.8 (ubuntu 9.10 and “route add 224.0.0.0…” )
windows : ruby 1.9.1 : Nok (no receive)
(TCP/IP on ruby 1.9/windows is realy broken !)
jruby 1.4.0 : error on socket.bind

by

==========================================================
here i my test code (working file in attachement) :

Thread.abort_on_exception = true
Socket.do_not_reverse_lookup = true

class MulticastSender
def initialize(ip,port)
@ip,@port=[ip,port]
@addr = IPAddr.new(@ip).hton + IPAddr.new(“0.0.0.0”).hton
@version=0
puts “Emitter mutlticast in " + ip + “/” + port.to_s + " …”
Thread.new { loop { run ; sleep(3) } }
end

def run
@version+=1
@version = @version % 1000
socket = UDPSocket.open
#socket.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, [10].pack(‘i’))
max=1+rand(3)
0.upto(max) { |no|
mess = Time.now.to_f.to_s
puts "sending mc " + mess
socket.send(mess, 0, @ip , @port)
sleep(0.01)
}
ensure
socket.close rescue puts $!.to_s
end
end

class MulticastReceiver
def initialize(ip,port)
@sip,@port=[ip,port]
@version=0
host = IPAddr.new(@sip).hton + IPAddr.new(“0.0.0.0”).hton
sock = UDPSocket.new
sock.bind(Socket::INADDR_ANY, port) if isWindows()

sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, host)
sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_MULTICAST_LOOP, 

“\000”) if defined?(Socket::IP_MULTICAST_LOOP)
sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_MULTICAST_TTL, 3)
if defined?(Socket::IP_MULTICAST_TTL)
sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, 3)
if defined?(Socket::IP_TTL)

sock.bind(Socket::INADDR_ANY, port) unless isWindows()

puts “Wait receiving mutlticast in " + @sip + “/” + port.to_s + " …”
Thread.new { loop { run(sock) } }
end
def run(sock)
msg, (family, port, hostname, address) = sock.recvfrom(1024)
d=Time.now
puts “MSG: from #{address} (#{hostname})/#{family} len #{msg.size} ==
#{msg.inspect }”
end
end