Ken Cornetet wrote:
Ping it first with Net::Ping

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Barry Brevik
Sent: Tuesday, December 08, 2009 7:44 PM
To: [email protected]
Subject: Help with socket timeout

I am using Active Perl 5.8.8 on Windows.
I am writing an app that opens a TCP socket to a network printer, and
then prints barcode labels on it. When the app starts up, it tries to
determine if the specific printer is reachable or not.

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
    }

<<attachment: angelos.vcf>>

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to