#!/usr/bin/perl
use strict;
use warnings;
use Socket; # so we can broadcast on udp
use POSIX;

my $msgsock; # the socket
my $portno = 53129;  # joke, sister's birthday, but likely to be unique
# inet_aton will take a hostname too, return undef if can't resolve, so
# we should be able to do this not-broadcast 'localhost' instead of bc address?
my $dest = sockaddr_in($portno, inet_aton('localhost')); # broadcast = "192.168.1.255"

my $cmd;
 
# program to test the record daemon.  Prompt for command, send it

 socket($msgsock,PF_INET,SOCK_DGRAM,getprotobyname("udp")) or die "socket:$!";

# setsockopt($msgsock, SOL_SOCKET, SO_BROADCAST,1) or die "setsockopt:$!";
# SOL_SOCKET is stack proto level, broadcast is the option, 1 is the value

while (1) {

 print "Input command to send recd daemon->";
 $cmd = <>;
 send($msgsock,"$cmd",0,$dest) or die "send:$!";

}
