0

Is the below code enough to disable the loopback interface from receiving my own outgoing multicast traffic? My udp code appears to still receive packets even when I pull the RJ-45 Ethernet cable from the NIC.

char loopch = 0;

if(setsockopt(sd, IPPROTO_IP, IP_MULTICAST_LOOP, (char *)&loopch, sizeof(loopch)) < 0){
    perror("Setting IP_MULTICAST_LOOP error");
    close(sd);
    return -1;}
user_ABCD
  • 347
  • 2
  • 15
  • Your edited question doesn't make sense. Why should pulling the cable prevent multicast loopback of your own sends? Multicast loopback doesn't have to go through the cable. – user207421 Mar 30 '16 at 22:45
  • If I am disabling multicast from being looped back to my lo interface with the above code, then my application shouldn't receive any traffic with the cable unplugged. Logical statement? Essentially I am saying the above code does not seem to disable multicast traffic from being looped back to my lo interface. – user_ABCD Mar 30 '16 at 22:57

1 Answers1

0

No. It does a different thing. It enables or prevents you from receiving your own outbound multicasts. See the man page.

However your code is wrong. The argument should be an integer.

I'm not aware of anything that controls whether you receive multicasts on the loopback interface.

user207421
  • 305,947
  • 44
  • 307
  • 483