UDP broadcasting & multiple interfaces

UDP broadcasting & multiple interfaces

Post by Andrew Gier » Fri, 05 Jul 1996 04:00:00


My program queries the interface configuration, and binds UDP sockets
to each interface address, each broadcast address, and INADDR_ANY. It
uses these sockets to receive datagrams which may be unicast to it,
but are usually broadcast. It sends replies to these datagrams, where
some of the information in the reply varies according to which socket
the request was received on. (This is not the programs main purpose,
it is part of a location discovery mechanism.)

I tried to make the code as tolerant as possible, and it basically
works on all the platforms I've tried, but there are some slight
anomalies that I would like to iron out if possible, and I would
appreciate any suggestions...

The problem is that on certain platforms, apparently only those where
the IP stack supports multicasting, the socket bound to INADDR_ANY is
picking up a duplicate of every incoming packet (or maybe only every
broadcast packet, I can't tell at the moment). I don't have an easy
way to detect the duplication.

Ideally, I would like to be able to ignore the duplicates, but on at
least some of the platforms I use, if I don't bind to INADDR_ANY, I
don't receive packets that are on the wire with INADDR_BROADCAST as the
destination. Worse, I really need to be able to keep *binary*
compatibility between two platforms (SCO 3.2.4 and OpenServer 5) where
OS5 duplicates packets and 3.2.4 does not.

[and just to forestall the otherwise inevitable, no, I don't currently
 have access to a copy of "TCP/IP Illustrated".]

"Usenet is like a herd of performing elephants with diarrhea; massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it." [Gene Spafford]