[NTLUG:Discuss] Routing BROADCAST messages.

Rusty Haddock/KD4WLZ rusty at fe2o3.lonestar.org
Sat Aug 19 02:03:45 CDT 2000


Steve Baker wrote:
    >Rusty Haddock wrote:
    > 
    >>    Sounds like the broadcast address you're using in your program might
    >> not be correct.  I'm almost thinking that might be '0.0.0.0' or
    >> '255.255.255.255'.
    >
    >Well, yes - I'm using INADDR_BROADCAST - which works on SGI IRIX
    >machines - and is what the man pages under Linux tell you to use.

Friendly reminder: Just 'cause it works on one vendor's machine doesn't
mean it's right! 

I believe that INADDR_ANY should be used only as an address when you're
binding a socket for RECEPTION of UDP broadcasts.  Think about it
-- to receive broadcasts you don't need an address of any sort, just a
port number! 

    >  "man ip" says:
    >
    >    "There  are  several  special  addresses:   INADDR_LOOPBACK
    >     (127.0.0.1)  always refers to the local host via the loop­
    >     back device; INADDR_ANY (0.0.0.0) means  any  address  for
    >     binding; INADDR_BROADCAST (255.255.255.255) means any host
    >     and has the same effect on bind as INADDR_ANY for histori­
    >     cal reasons."
    >
    >...so either 0.0.0.0 or 255.255.255.255 should be OK...but
    >evidently not!

255.255.255.255 say "send this packet to every possible IP address." Well,
at least as many as possible given what all the routers, bridges, filters,
etc.  permit. 

The 0.0.0.0 address I believe should only be used as I described above. 
Well, at least for binding sockets, anyhow.

    >I'd quite like to *understand* why what I'm doing is wrong.

Unfortunately the books that I want to quote are on my book shelf at work.
Luckily my library is cataloged in a database here at home.  Here's one
book that really helped me out a lot with this UDP broadcasting:

    "UNIX Network Programming" by W. Richard Stevens

    >>  I've attached a UDP broadcaster, in C, that I wrote
    >> many moons ago.  It's intention was to broadcast small packets of data
    >> and, any machine on the net that wanted to listen would simply listen on
    >> the pre-arranged IP port and soak up the data.  Maybe it'll help.
    >
    >Thanks that's exactly what I'm trying to do - I'll give it a whirl.

More answers, or attempts thereof, in the next message.

	-Rusty-

-- 
   _____        Rusty Haddock  =  KD4WLZ  =  rusty at fe2o3.lonestar.org
|\/   o \   o
|   (  -<  O o  Thanks, Sparky!          Charles M Schulz (1922-2000)
|/\__V__/




More information about the Discuss mailing list