Link to home
Start Free TrialLog in
Avatar of targetddc
targetddc

asked on

server/client pair using a udp socket

the server should receive 1 and only 1 client and print "." to the shell once a second.  the socket should listen on port 9999, close the connection, remove the socket, and exit on the TERM sig.

I have included some code as follows:
#!/usr/bin/perl
use Socket;
socket(SERVER,PF_INET,SOCK_DGRAM, 0) ;
my $sin = sockaddr_un(9999,INADDR_ANY);
bind (SERVER,$sin) || die $!;
this is where I am getting confused because I've read something similar to this
use IO::Socket;

$socket= IO::Socket::INET->new(PeerAddr =>$remote_host,
                                                 PeerPort  =>9999,
                                                 Proto       =>"udp",
                                                 Type       =>SOCK_DGRAM)  || die "Couldn't connect to $remote_host:$remote_port : $@\n";
                                               
                                           
                                               


ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of targetddc
targetddc

ASKER

ozo,
good show.  Curious as to if this can be written using a server/client pair?  Perhaps I'm stating the question wrong.  Is there a way to write a server program and a client program?
Regards,
tddc
Thanks for your input!!!