#! /usr/bin/perl -w use strict; use IO::Socket::INET; my($host, $port) = qw(localhost 12345); my $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => 'udp') || die; my $retry = 6; while ($retry--) { unless (send($sock, "ping!", 0)) { print "Host is up? ($!)\n"; } sleep(1); }