We currently simply delete socket objects when we no longer need them. For UDP multicast we need time to unregister using IGMP. Trying to run this in a destructor is an anti-pattern. We need to define a lifecycle for these abstract sockets where we remove them from use but continue to service them until the say they are ready for deletion. This would give us time to try to deregister/leave the multicast group and possibly retry if the system were out of tx buffers. Furthermore, a well-optimized system would run this IGMP de-registration step at a lower priority only sending the IGMP when there wasn't a lot of outgoing traffic in the queues.
We currently simply delete socket objects when we no longer need them. For UDP multicast we need time to unregister using IGMP. Trying to run this in a destructor is an anti-pattern. We need to define a lifecycle for these abstract sockets where we remove them from use but continue to service them until the say they are ready for deletion. This would give us time to try to deregister/leave the multicast group and possibly retry if the system were out of tx buffers. Furthermore, a well-optimized system would run this IGMP de-registration step at a lower priority only sending the IGMP when there wasn't a lot of outgoing traffic in the queues.