Subject: broadcast using CMU-tek
From: [email-masked] (Przemek Klosowski)
Date: Thu, 17 Jun 1993 02:07:04 GMT
Newsgroups: vmsnet.networks.tcp-ip.cmu-tek

Hello,

We have been using client CMU-tek for some time; now, however, I need
to write a program to broadcast UDP packets to the network. The idea
is that when our vaxes collect a new data record they would broadcast
this fact, avoiding the need for continuous polling that we do now. A
short Perl code that does what I need on Unix is enclosed at the end
of this article.

What is the best way to do it? The programming section of the manual
mentions that ipacp enables new QIO codes that deal with the TCP/IP
operations; however, I could't figure out how to write the broadcast
code. Also, I couldn't figure out where are the files that define
those QIO codes.

I also found out about the SOCKIT library; it looks as if I could take
the Unix code directly to it; but again, I couldn't figure out how do
I get all the magic constants (AF_INET, SO_BROADCAST, etc)---there are
no .h files in the SOCKIT directory.

Thanks for any help you may provide

	przemek

$port = 8080;			
$sockaddr = "S n a4 x8";($name,$aliases,$proto) = getprotobyname('udp');

chop($hostname = `hostname`);
($name,$aliases,$type,$len,$myaddr) = gethostbyname($hostname);
@myaddr=unpack("C4",$myaddr);
pop(@myaddr);push(@myaddr,255); # works only for ff:ff:ff:00 subnet mask
$broadaddr=pack("C4",@myaddr);

$me   = pack($sockaddr,&AF_INET, 0,     $myaddr);
$them = pack($sockaddr,&AF_INET, $port, $broadaddr);

socket(S, &AF_INET, &SOCK_DGRAM, $proto) || die $!;
setsockopt(S,&SOL_SOCKET,&SO_BROADCAST,1) || die $1;
bind(S, $me) || die $!;

send(S,"01234567 Hello everyone 01234567\n",0,$them) || die $!;

--
			przemek klosowski ([email-masked])
			Reactor Division (bldg. 235), E111
			National Institute of Standards and Technology
			Gaithersburg, MD 20899,      USA

			(301) 975 6249