NW 67 - Receiving UDP Broadcasts While Sending from a Secondary Address (8-May-2000)Q: I'm writing an application that needs to receive UDP broadcasts. I also want to send unicast replies; however, when running on a single-link multi-homed machine, I want to control the source IP address from which the replies originate. How do I do this? A: To listen to UDP broadcasts (and multicasts), you must
create an endpoint and bind it to
If you wish to send and receive on the same port number,
you must set the
The only gotcha here is that, if someone unicasts a packet to one of your IP addresses, the corresponding sending endpoint will receive it. Your sending endpoints must be prepared for this; typically, they either discard the packet or pass it to the logic used for the receiving endpoint. Technical Q&A | Contents Previous Question To contact us, please use the Contact Us page. |