[Live-devel] Groupsock doesn't bind to Multicast Address

Sanjeev Sood sanjeev.sood at gmail.com
Tue Oct 3 00:36:24 PDT 2006


Hello,

I am relatively new user to the Live Media library. In our application, we
would like to bind to a multicast address in addition to binding to the
local port number. This is so that we *only* receive packets destined for a
given *Multicast address & port* combination and prevent other datagrams
destined for that same port from being deliverd to our socket.

To achieve this, I am using "ReceivingInterfaceAddr" global variable to set
our MULTICAST address. This allows Groupsock to bind to this address,
however following code in the GroupsockHelper.cpp fails:

// socketJoinGroup() code snippet
imr.imr_multiaddr.s_addr = groupAddress;
  imr.imr_interface.s_addr = ReceivingInterfaceAddr;
  if (setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
                 (const char*)&imr, sizeof (struct ip_mreq)) < 0) {

This is because ReceivingInterfaceAddr being a Multicast address, is not a
valid interface address.

However, if the above one line was modified as follows to use the INADDR_ANY
as the interface address when ReceivingInterfaceAddr is a multicast address,
it should work:

// change imr.imr_interface.s_addr = ReceivingInterfaceAddr; to following:

if (IN_MULTICAST(ntohl(ReceivingInterfaceAddr))) {
    // Bound to MULTICAST Address, so use INADDR_ANY as the i/f address
    imr.imr_interface.s_addr = INADDR_ANY;
  }
  else {
    // Bound to UNICAST Address, so use this address as the i/f address
    imr.imr_interface.s_addr = ReceivingInterfaceAddr;
  }

This simple change enables applications interested in receiving specific
packets only.

Here are my questions:

   1. Is this an acceptable solution to my problem? If so, can this
   change be included in your code base and future release?
   2. If not, is there an existing solution to this problem?

I will sincerely appreciate any input and guidance on this issue.

Best regards,
-Sanjeev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.live555.com/pipermail/live-devel/attachments/20061003/ad5af490/attachment.html 


More information about the live-devel mailing list