I am working on a UDP multicast library and asked a question on how to properly handle link failures, disconnected / reconnected network cables, etc.
In my test, I have the following setting:
- 2 sA and sB servers
- sA sends UDP multicast data, and sB receives multicast data.
- servers connect through Cisco Layer 2 Gigabit Switch
As an example, when I join a multicast group on sB, I start to receive data on this socket from sA multicast packets.
Now that I have unplugged / unplugged the network adapter that the sB multicast receiver is attached to, I am not getting any socket level errors (like in Socket.ReceiveAsync), which I assume is expected since UDP is contactless, however I was hoping that I will receive some kind of notification / exception as the IP address that the multicast receiver will inevitably become unavailable.
In any case, when I reconnect this network adapter, I do not receive any more data, although the sender still sends to the same multicast group. I was hoping that the kernel would indeed handle the reunion of the multicast group after a hardware failure, but it seems like it is not. However, since I am not getting any socket level errors, I really don't know how to detect channel failure for a multicast receiver? Are there certain socket parameters that must be set in order for the kernel to join a multicast group? The only option I have come with so far is to listen to System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged events and try to re-check when I get a notification that the local IP address,which I have to bind becomes available again. How do other multicast applications handle this scenario?
,
Tom