A socket didn't join a multicast group but it can receive data.
c, linux, multicast, network-programming
Solution
The kernel simply doesn't filter incoming multicast packets based on which multicast groups a socket is a member of. If you don't add a socket to a group, it may still receive multicasts to a group if other sockets on the same system are members. (I'm not sure what happens if a multicast arrives but no sockets are members. You can test if you like.)
Note that the kernel in fact does track group ownership, per-socket even. It has to, or it couldn't properly implement the client side of the IGMP protocol. For instance, the kernel needs to reply to various kinds of IGMP queries from the router (where it is asked what groups the host is joined to), and also so it knows to send a Leave Group message when there are no more sockets joined to a specific group.
Problem
when I created two udp sockets and I bind them to INADDR_ANY and same port number. but one of them joined a multicast group. but both of them can receive data from the same multicast group, even one of sockets didn't join to the multicast group.