Hi,
I'm working on a UDP Multicast library and got a question on how to properly handle link failures, disconnected/reconnected NIC cables, etc.
In my test I have the following setup:
- 2 servers sA and sB
- sA is sending UDP multicast data and sB is receiving multicast data
- servers are connected through a Layer 2 Cisco gigabit switch
As an example, when I join the multicast group on sB I start receiving data on that socket from sA's multicast packets.
Now, when I disable/unplug the NIC to which the multicast receiver sB is bound, I'm not receiving any socket level errors (e.g. in Socket.ReceiveAsync), which I guess is expected as UDP is connectionless, yet I was hoping I would get some kind of notification/exception as the IP that the multicast receiver is bound to becomes unavailable.
Anyways, when I reenable that NIC, I'm not receiving any more data although the sender is still sending on the same multicast group. I was hoping that the Kernel would actually handle rejoining the multicast group after a hardware link failure but looks like it doesn't. However, since I'm not getting any socket level errors either, I don't really know how to detect a link failure for a multicast receiver? Are there certain socket options that need to be set so the kernel would rejoin a multicast group? The only option I came up with so far is listening for System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged events and attempt to rebind when I get a notification that the local IP I have to bind to becomes available again. How are other multicast applications handling that scenario?
Thanks,
Tom