Blocking does not resolve the problem. Here is the code, I am still facing the issue the program is not killed after alarm but sits back waiting and waiting.
my $socket_resp = IO::Socket::INET->new(LocalPort => $response_por
+t, Proto => 'udp', Blocking => 1, Timeout => undef);
print "FW Machine: Waiting for Command Response On Port $response_
+port\n";
eval {
local $SIG{ALRM} = sub {
die "Timed Out";
};
alarm 10;
while (1) {
my $recieved_data;
$socket_resp->recv($recieved_data, 1024);
alarm 10;
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:$response_por
+t => $recieved_data\n";
if ($recieved_data =~ m/^done/i) {
last;
}
}
}
alarm 0;
};
alarm 0;
if ($@ =~ /Timed Out/i) {
print "Timed-Out waiting for infinite loop to finish\n";
}
$socket_resp->close();
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.