CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Win32 and alarm(): Edit Log



alager
Novice

Sep 3, 2009, 3:57 PM


Views: 581
Win32 and alarm()

I'm making a UDP test script and the receive portion uses alarm() to test for timeouts. The problem is that calling the recv() method of IO::Socket seems to cause the alarm feature to either be reset, or just not able to create the signal.

alarm() by itself works:

Code
$SIG{ALRM} = sub { die "alarm time out" }; 
alarm(1);
sleep 4;
alarm(0);

This gives the message "alarm time out"

However, if I try this instead, the code hangs forever if there is nothing to receive, the alarm never activates

Code
$SIG{ALRM} = sub { die "alarm time out" }; 
alarm($TIMEOUT);
$sock->recv($msgRX, $MAXLEN) or die "recv: $!";
alarm(0);


I've tried this with and without an eval around it, it doesn't seem to make a difference.

Any help on this would be appreciated.

Thanks,
Aaron


(This post was edited by alager on Sep 4, 2009, 9:06 AM)


Edit Log:
Post edited by alager (Novice) on Sep 4, 2009, 9:06 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives