zahra@wolfen.cc.uow.oz (Andrew Zahra Telecom) (01/18/91)
I am trying to write a program which will be able to broadcast messages to all other machines on the local network. I am using a datagram socket and have not had much success with various combinations of setting socket options (SO_BROADCAST) and doing a connect to INADDR_BROADCAST. I either get a network unreachable error or an error from the bind indicating it can't allocate the requested address. If anyone has a minimal code example of how to do this it would be very welcome and may stop me tearing my hair out. Thanks in advance, Andrew Andrew Zahra AARNet zahra@wolfen.cc.uow.edu.au Telecom Australia ACSNet zahra@wolfen.cc.uow.oz.au Customised Software Solutions Centre
tkld@cs.ed.ac.uk (Kevin Davidson) (01/28/91)
zahra@wolfen.cc.uow.oz (Andrew Zahra Telecom), babbling inanely in article <6746@wolfen.cc.uow.oz>, claimed: >I am trying to write a program which will be able to broadcast messages to all >other machines on the local network. I am using a datagram socket and have not >had much success with various combinations of setting socket options >(SO_BROADCAST) and doing a connect to INADDR_BROADCAST. I either get a network >unreachable error or an error from the bind indicating it can't allocate the >requested address. > I too am trying to do this, and get the same kinds of errors. I notice there is a comment in the Sun include file <netinet/in.h> that INADDR_BROADCAST should be masked - how ? To what ? Can I limit the broadcast to subnets - I don't really want to wake up every machine on a large net, just the local ones? I have also tried the code in the Sun manual that queries each ether interface for broadcast addresses and tries those. My messages just seem to disappear. (sendto() thinks everything's hunky-dory, but I can't recvfrom() it.) >If anyone has a minimal code example of how to do this it would be very welcome >and may stop me tearing my hair out. Baldness is a sign of maturity....:-) -- .Kevin. <tkld@lfcs.ed.ac.uk> <tkld@tardis.cs.ed.ac.uk>