I’m writing a gem which binds multiple sockets to the same UDP
multicast port, basically like so…
socket = UDPSocket.new socket.setsockopt( Socket::SOL_SOCKET, Socket::SO_REUSEPORT,
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
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?