Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

multicast and windows

10 views
Skip to first unread message

Regis Siger

unread,
Dec 9, 2009, 7:42:25 AM12/9/09
to
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(TM) Client VM 1.6.0_16) [x86-java]

Attachments:
http://www.ruby-forum.com/attachment/4309/sim.rb

--
Posted via http://www.ruby-forum.com/.

Roger Pack

unread,
Dec 9, 2009, 3:09:24 PM12/9/09
to
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

Regis Siger

unread,
Dec 9, 2009, 8:16:24 PM12/9/09
to
Roger Pack 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

Roger Pack

unread,
Dec 9, 2009, 8:45:46 PM12/9/09
to

> code is in sim.rb, attachment of first post

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

Roger Pack

unread,
Dec 9, 2009, 8:47:19 PM12/9/09
to

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

Did you try 1.9.1 on doze?

Regis Aubarede

unread,
Dec 10, 2009, 6:50:26 AM12/10/09
to
Roger Pack 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

Attachments:
http://www.ruby-forum.com/attachment/4310/test_mc.rb

Roger Pack

unread,
Dec 10, 2009, 8:28:16 AM12/10/09
to

> 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

Roger Pack

unread,
Aug 5, 2010, 7:57:58 PM8/5/10
to

> 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).

Charles Oliver Nutter

unread,
Aug 6, 2010, 8:18:15 PM8/6/10
to
On Thu, Dec 10, 2009 at 6:50 AM, Regis Aubarede
<regis.a...@gmail.com> 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

0 new messages