#!/usr/local/bin/perl use constant MYPORT => 10002; use constant REMOTEPORT => 10001; use constant REMOTEHOST => '192.168.23.1'; use constant STRING => 'PING'; use Socket; use IO::Socket; # create a socket my $sock = new IO::Socket::INET(LocalPort => MYPORT, Proto => 'udp')     or die "Can't create socket: $!"; my ($remote,$input,$c); $remote = sockaddr_in(REMOTEPORT, inet_aton(REMOTEHOST)); my $rc = $sock->send(STRING,length(STRING),$remote); die "$! $@" unless $rc; $rc = $sock->recv($input,32768,0); die "$! $@" unless $rc; print "received: $input\n";