The Linux kernel does not monitor the status of IGMP connections. IGMP is a router protocol. Sending an IGMP connection to a multicast group simply tells the router that it should forward packets to the specified address and port. Note that routers must be able to speak IGMP.
This means that although you used setsockopt() to join a multicast group, membership is not tracked by the kernel in the kernel, as you might expect. The kernel simply sends an IGMP connection packet to the router. You can verify this using wirehark or something else.
Since the kernel does not monitor the IGMP socket state, inbound traffic at this address and port is βnormalβ traffic for the kernel.
So, if you bound both sockets to the same address and port, and then sent an IGMP connection using this address and port, it is expected that packets will be available on both sockets.
By the way: why do you need two sockets tied to the same address and port?
UPDATE: After explaining @Ambroz Bizjak (thanks), it is not true that the Linux kernel does not monitor the status of IGMP connections. It does. But he does not use this information to decide which packets should be sent to which socket if several sockets are bound to the same address and port.
source share