Forum: Ruby on Rails Ruby UDP Multicasting Binding Insanity

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Preston L. (Guest)
on 2007-07-28 04:08
(Received via mailing list)
I'm writing a gem which binds multiple sockets to the same UDP
multicast port, basically like so..

    socket =
    socket.setsockopt( Socket::SOL_SOCKET, Socket::SO_REUSEPORT,
[1].pack("i_") )
    socket.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP,
    socket.bind(Socket::INADDR_ANY, port)
    data, meta = socket.recvfrom 1024

..which is working fine.. in OS X. But no love on my Solaris 10 x64
box. The problem? AFAICT, the available options come straight from
the platforms C setsockopt implementation, which is platform
dependent, and SO_REUSEPORT isn't defined on Solaris. I haven't
gotten to Windows yet but I'm guessing I'll have the same issue.

So, it seems that Ruby's socket library is a bit fubar in that
Socket's constants..

    irb(main):008:0> Socket.constants.sort.each do |c| p c; end

..vary by platform. Anyone have a Better Way of binding twice (or
more) to the same UDP multicast port--or doing any low-level socket
stuff--in a cross-platform-sane manner?

This topic is locked and can not be replied to.