3
votes

I am trying to write an application that listens to a number of multicast groups using Windows sockets.

The problem I'm running in to is that when I go to bind the socket, if I try to bind to the multicast group address and port this fails with WSAEADDRNOTAVAIL. If I instead bind to INADDR_ANY and the port, then I can still receive other unrelated traffic destined for the same port.

When I implemented the same thing in Linux, I didn't have any issues binding to the multicast address (in fact, I saw it recommended several places to avoid getting unrelated traffic for the port).

Is this just not available with Windows sockets? I assume I could filter traffic myself by using WSARecvFrom and peeking at the headers, but I'd rather a simple solution if one exists.

Also, this is running on Windows Server 2008.

1
I'm having the very same issue with Windows sockets. It looks like Windows sockets don't accept bindings on multicast IPs, which makes it imposible to prevent the socket from receiving unrelated trafic from other IP on the same port. - mtctn

1 Answers

2
votes

While the doc for bind() does not say that this unsupported, it does say in the remarks:

For multicast operations, the preferred method is to call the bind function to associate a socket with a local IP address and then join the multicast group....

Maybe this scheme will yield better results?