C, Linux: Receiving data from multiple multicast address on same port - how to distinguish them?

Posted by Gigi on Stack Overflow See other posts from Stack Overflow or by Gigi
Published on 2010-04-30T02:18:37Z Indexed on 2010/04/30 2:27 UTC
Read the original article Hit count: 323

Filed under:
|
|

2 vote down star

I have an application that is receiving data from multiple multicast sources on the same port. I am able to receive the data. However, I am trying to account for statistics of each group (i.e. msgs received, bytes received) and all the data is getting mixed up. Does anyone know how to solved this problem? If I try to look at the sender's address, it is not the multicast address, but rather the IP of the sending machine.

I am using 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 also:

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

I appreciate any help!!!

© Stack Overflow or respective owner

Related posts about multicast

Related posts about same