title: C, Linux: Receiving data from multiple multicast address on same port - how to distinguish them?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2741611/receving-multiple-multicast-feeds-on-the-same-port-c-linux">Receving multiple multicast feeds on the same port - C, Linux</a>  </p>
  </blockquote>
  
  
  
  <p>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.</p>
  
  <p>I am using the following socket options:</p>
  
  <pre><code>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, &amp;mreq, sizeof(mreq));
  </code></pre>
  
  <p>and also:</p>
  
  <pre><code>setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &amp;reuse, sizeof(reuse));
  </code></pre>
  
  <p>I appreciate any help!!!</p>