// JP opened flex table

Click to See Complete Forum and Search --> : is IP_MULTICAST_IF necessary?


nmarler
March 12th, 2004, 11:20 PM
If I join a multicast group on a specific local interface, is it necessary for me to also set IP_MULTICAST_IF, or would that be redundant?

I have multiple adapters in my PC, I need to both send and receive off only one specific adapter.

struct ip_mreq mreqv4;
SOCKET s;
DWORD localadapter = inet_addr("192.168.1.1");

// TO DO: bind socket to INADDR_ANY

mreqv4.imr_multiaddr.s_addr = inet_addr("239.3.4.5"); // multicast
mreqv4.imr_interface.s_addr = localadapter;

// join the mcast group
setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*)&mreqv4, sizeof(mreqv4));

// is the above enough to send and receive off the local
// port?

// is this redundant?
setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, (char*)&localadapter, sizeof(localadapter));

//JP added flex table