tags:

views:

24

answers:

1

If I broadcast using a UDP socket using sendto() and call recvfrom() immediately. I am receiving the broadcast message that I have sent from the same PC a little while ago? Can this loop back kind of thing be avoided some how?? any explanation why am I experiencing such loop back kind of thing? I mean how long does broadcast message stays in the local n/w??

A: 

This is normal behavior. You need to read up on how UDP broadcasting actually works. Your local PC is on the same network that you are broadcasting to, so it receives the broadcast it is sending. You cannot avoid the broadcast being sent back to the local PC, but what you can do is look at the sending IP/Port that recvfrom() reports and ignore the message if it came from the same process that owns the socket that broadcasted it.

Otherwise, switch to Multicasting instead of UDP broadcasting (especially since UDP broacasting is not supported in IPv6 anyway). With Multicasting, receivers have to subscribe to the Multicast in order to receive messages, so simply do not have your sending PC subscribe to its own Multicast.

Remy Lebeau - TeamB