ADC Home > Reference Library > Technical Q&As > Networking > Carbon >

Not Recommended Documentclose button

Important: The information in this document is Not Recommended and should not be used for new development.

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

Receiving UDP Broadcasts


Q: I've created an Open Transport UDP endpoint to listen for UDP broadcasts. However the endpoint never receives any UDP broadcast messages. A packet sniffer shows that the UDP packet is actually arriving at the machine. What's going on?

A: There are two likely causes for this problem:

  1. The port you're binding to is already in use, so OT reroutes your bind request to another port. You can check for the problem programatically by passing a retAddr parameter to OTBind, and checking that the resulting fPort field matches the port you requested. One common cause of this is that the port is still in use by your own application because of the IP reuse address delay. You can eliminate this delay using the code described in Q&A NW 28 "TCP Application Acquires Different Port Address After Relaunch". That Q&A is specific to TCP endpoints, but the technique works for both TCP and UDP endpoints.
  2. You are passing a specific IP address to OTBind. General purpose programs that want to listen for connections/datagrams should always bind to kOTAnyInetAddress (ie 0), not to a specific IP address. On a multi-homed machine, if you bind to a specific address, you will only receive connections/datagrams addressed to that IP number. This is useful if you're writing a server that reacts differently depending on which IP address it receives a connection on, but most general purpose code should not care which IP address the connection/datagram was sent to. In this specific case, if you bind a UDP endpoint to a specific IP address, you will not receive broadcast packets on that endpoint because they were not sent to the specific IP address you bound to.

[Nov 17 1997]


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.