alarm() on Windows cannot interrupt system calls, so there should be another answer.(see Alphabetical Listing of Perl Functions)
Can you try the third method from Re: what does timeout mean in IO::Socket::INET ?? It seems to be the right thing.
Also, I may have misunderstood somethng, but Blocking is set to 1 in your code. If all else fails, the following (ugly) kludge can help:
my $socket_resp = IO::Socket::INET->new(LocalPort => $response_port, P +roto => 'udp', Blocking => 0, Timeout => undef); ... $received_data=&timeout_recv($socket,1024,10); ... sub timeout_recv { my $return; my $buf; my $cnt=0; for (1..$_[2]) { # $_[2] is timeout $_[0]->recv($buf,$_[1]-$cnt) // 0; # $_[1] is count of bytes to rece +ive $cnt += length $buf; $return .= $buf; return $return if $cnt == $_[1]; sleep 1; # the ugliest line } die "Timed Out"; }
In reply to Re^3: alarm not working
by aitap
in thread alarm not working
by anshumangoyal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |