anshumangoyal has asked for the wisdom of the Perl Monks concerning the following question:
sub ReceiveResponse { my $port = shift; my $time_out = 1; print "FW Machine: Waiting for Command Response On Port $recv_port +\n"; eval { local $SIG{ALRM} = sub { die "Timed Out"; }; my $socket_resp = IO::Socket::INET->new(LocalPort => $recv_por +t, Proto => 'udp', Timeout => undef); alarm 10; while (1) { my $recieved_data; $socket_resp->recv($recieved_data,1024); my $peer_address = $socket_resp->peerhost(); my $peer_port = $socket_resp->peerport(); if ($peer_address eq $send_ip_address) { my $desti = GetIP(); chomp($recieved_data); print "$peer_address:$peer_port > $desti:$recv_port => + $recieved_data\n"; if ($recieved_data =~ m/^done/i) { last; } } } $socket_resp->close(); alarm 0; }; alarm 0; if ($@ =~ /Timed Out/i) { print "Timed-Out Receiving Data from UDP\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: alarm not working
by aitap (Curate) on Jul 11, 2012 at 09:19 UTC | |
by anshumangoyal (Scribe) on Jul 12, 2012 at 16:35 UTC | |
by aitap (Curate) on Jul 13, 2012 at 17:17 UTC | |
|
Re: alarm not working
by BrowserUk (Patriarch) on Jul 11, 2012 at 09:28 UTC | |
by anshumangoyal (Scribe) on Jul 12, 2012 at 16:26 UTC |