4

I have two applications that need to subscribe to the same multicast group / port combination. Currently, the only way I can handle this is by building a proxy application that subscribes to the multicast group and forwards the received traffic to each application over separate TCP connections. I would like to get rid of the proxy application and let each app subscribe to the multicast group itself, but I get a socket exception "Only one usage of each socket address is normally permitted".

Is there any way around this? Why is only one subscription to a given multicast group per computer allowed?

ConditionRacer
  • 4,418
  • 6
  • 45
  • 67

1 Answers1

4

Not entirely sure if it's allowed, but look here for a possible solution:

Sending and receiving UDP packets between two programs on the same computer

Ultimately, you wouldn't instantiate the UdpClient with the endpoint specified. You would instead instantiate a new UdpClient, set SocketOptions to reuse the endpoint, and then bind:

IPEndPoint localpt = new IPEndPoint(IPAddress.Any, 6000);
UdpClient udpListener = new UdpClient();
udpListener.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
udpListener.Client.Bind(localpt);

The above answer is for sending/receiving on the same port, so not sure if it will work for receiving in 2 separate applications on the same port. Give it a try and let us know.

Community
  • 1
  • 1
SPFiredrake
  • 3,852
  • 18
  • 26