Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!ukc!edcastle!cs.ed.ac.uk!tkld From: tkld@cs.ed.ac.uk (Kevin Davidson) Newsgroups: comp.unix.programmer Subject: Re: broadcast sockets Keywords: socket Message-ID: <5120@skye.cs.ed.ac.uk> Date: 28 Jan 91 15:39:45 GMT References: <6746@wolfen.cc.uow.oz> Sender: nnews@cs.ed.ac.uk Reply-To: tkld@lfcs.ed.ac.uk (Kevin Davidson) Organization: CS4, Edinburgh University Lines: 28 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 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.