ADC Home > Reference Library > Technical Q&As > Legacy Documents > Networking >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

Receiving UDP Broadcasts While Sending from a Secondary Address

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 kOTAnyInetAddress ( If you send your unicast replies from the same endpoint, the replies will have their source address set to the default IP address of the interface from which the packets were sent. To get around this, you must create an endpoint for each possible source address, bind the endpoint to the corresponding IP address, and then send the packet using the appropriate endpoint.

If you wish to send and receive on the same port number, you must set the IP_REUSEADDR option on each endpoint before binding it. This prevents OTBind from returning the kOTAddressBusyErr error.

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.

[May 08 2000]

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.