C, Linux: retrieving data from multiple multicast addresses on the same port - how to distinguish them?

Possible duplicate:
Receiving several multicast channels on one port - C, Linux

I have an application that receives data from multiple multicast sources on the same port. I can get the data. However, I try to take into account the statistics of each group (i.e. received messages, received bytes), and all data is mixed. Does anyone know how to solve this problem? If I try to look at the sender address, this is not the multicast address, but the IP address of the sending machine.

I use the following socket options:

struct ip_mreq mreq;         
mreq.imr_multiaddr.s_addr = inet_addr("224.1.2.3");         
mreq.imr_interface.s_addr = INADDR_ANY;         
setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));

and:

setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &reuse, sizeof(reuse));

I appreciate any help !!!

+3

All Articles