in reply to Implementing Sockets Timeouts

Hi Anonymous Monk,

Internally, IO::Socket uses non-blocking i/o with regard to timeouts. I would specify an integer for the timeout period since I didn't see where it was passed in via a form. Something like this:

#!/usr/bin/perl -wT use strict; use CGI qw( :standard ); use IO::Socket; my $client = IO::Socket::INET->new ( PeerAddr => $clientIP, PeerPort => $clientPort, Proto => "tcp", Type => SOCK_STREAM, Timeout => 10 ); $client or die $@, "\n"; #Remainder of code...

If the connection occurs within the alloted time frame, the IO::Socket obj. is returned and saved in $client. If not, the error will be stored in $@ with the error message "IO::Socket::INET:Operation now in progress".
Hope this helps,
-Katie.

Replies are listed 'Best First'.
Re: Re: Implementing Sockets Timeouts
by Anonymous Monk on Aug 02, 2002 at 08:52 UTC
    Hi Katie,

    Thanks for your help. Your suggestion on the error message contained in $@ solved my problem.

    Chris