Why not do it the simple way?

use IO::Socket;
my $sock = IO::Socket::INET->new($somewhere);
$sock->timeout($n);




-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Bill Luebkert
Sent: Thursday, December 10, 2009 12:34 PM
To: [email protected]
Subject: Re: Help with socket timeout

Angelos Karageorgiou wrote:
> 
> a better way to handle it  would be via alarm(ed) timeouts like this
> 
> eval {
>     local $SIG{ALRM} = sub { die "alarm\n" };       # NB \n required
>     alarm $timeout;
> 
>     A lot of socket work done here
> 
>     alarm 0;
> };
> die if $@ && $@ ne "alarm\n";       # propagate errors
> 
>      # the connection is fine here
>     }

Have you tried that on Windoze ?  I'm not sure you'll get the
expected results.  I don't think timeouts will work on sockets
under Windoze, but you may be able to do something using the
Windows API or using non-blocking I/O on the connect.  I don't
have time to experiment right now or I'd give you some better
advice.
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to