#!/usr/bin/perl use strict 'vars'; use warnings; use IO::Socket::INET; my $port="50000"; my $socket; my $get; my $stuff; $socket = new IO::Socket::INET ( LocalPort => $port, Proto => 'udp', ) or die "ERROR in socket creation: $!\n"; eval { local $SIG{ALRM} =sub {die}; alarm(5); $socket -> recv($get, 1024); alarm(0); }; if ($@) { $socket->send($stuff); }