Paul D.
Paul D.

Reputation: 1845

Cannot bind to multicast address (Windows)

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.

Upvotes: 5

Views: 5423

Answers (1)

ribram
ribram

Reputation: 2460

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?

Upvotes: 3

Related Questions