From: Nat Pryce Date: 2001-07-31T21:08:33+09:00 Subject: [ruby-talk:18883] IP multicast with UDPSocket This is a multi-part message in MIME format. ------=_NextPart_000_0082_01C119C0.9C6CDD40 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Does anyone have example code for joining/leaving multicast groups using = the UDPSocket? Also, how is it possible to write this in a platform independent manner? = As far as I can tell, the API for setting socket options seems to be = completely platform dependent. It is also hard to code to, because you = have to build strings of binary data that contain valid C structures = used by the OS APIs. Would there be interest in code to replace or wrap = setsockopt/getsockopt with methods and attribute accessors? =20 For example: socket =3D UDPSocket.new socket.add_membership "240.212.100.200" # or whatever a valid IP group = number is socket.ip_multicast_ttl =3D Socket::TTL_LOCAL_NETWORK socket.ip_multicast_loopback =3D false socket.sol_reuse_address =3D true socket.bind( 15630 ) Or: socket =3D TCPSocket.new( 'www.b13media.com', 80 ) socket.sol_sndbuf =3D 512 socket.sol_rcvbuf =3D 4096 Would this be a useful RCR? Cheers, Nat. ------=_NextPart_000_0082_01C119C0.9C6CDD40 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Does anyone have example code for = joining/leaving=20 multicast groups using the UDPSocket?
 
Also, how is it possible to write this = in a=20 platform independent manner?  As far as I can tell, the API for setting socket options seems to be = completely=20 platform dependent.  It is also hard to code to, because you = have to=20 build strings of binary data that contain valid C structures used by the = OS=20 APIs.  Would there be interest in code to replace or wrap=20 setsockopt/getsockopt with methods and attribute accessors?  =
 
For example:
 
socket =3D UDPSocket.new
socket.add_membership = "240.212.100.200"  # or=20 whatever a valid IP group number is
socket.ip_multicast_ttl =3D=20 Socket::TTL_LOCAL_NETWORK
socket.ip_multicast_loopback =3D = false
socket.sol_reuse_address =3D = true
socket.bind( 15630 )
 
Or:
 
socket =3D TCPSocket.new( = 'www.b13media.com', 80=20 )
socket.sol_sndbuf =3D 512
socket.sol_rcvbuf =3D 4096
 
Would this be a useful = RCR?
 
Cheers,
    Nat.
 
 
------=_NextPart_000_0082_01C119C0.9C6CDD40--