[phobos] joining multicast groups with std.socket

Peter Ryan peter at peterryan.net
Tue Jan 4 06:02:40 PST 2011


I am trying to listen to a multicast group using the std.socket library. I
have looked at the documentation but I do not see a way to join a multicast
group. The code I have so far is pasted below. I am looking for
the IP_ADD_MEMBERSHIP socket option (along the lines of
http://www.cs.unc.edu/~jeffay/dirt/FAQ/comp249-001-F99/mcast-socket.html)
and can't find within the library.

Let's assume I am trying to listen to 225.0.0.37/12345

Can someone help me with a snippet on some d code that will do this?

I appreciate the help!

Peter



auto socket = new UdpSocket();
auto address = new InternetAddress(12345);
socket.bind(address);
auto multicastAddress = new InternetAddress("225.0.0.37");

/// The below naturally does not work and I can't seem to find

// How do I join the multicast address above?

byte[256] buffer;
int read = socket.receiveFrom(buffer);
printf("Received bytes %i", read);
return 0;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20110104/c16142b6/attachment.html>


More information about the phobos mailing list