Need to handle the NNTP connection timeout in my code
am 08.02.2007 10:51:49 von Naren
Hi All,
I have a perl script that use cpan NNTP.pm perl module for NNTP
connection. I am passing the timeout as one parameter while opening
the NNTP connection. I am intentionally timing out the NNTP
connection. When I open the connection in debug mode, then I could see
my connection is timing out. My question is how do I capture this
timing out error in my code.
Any suggesstion would be aprreciated.
Re: Need to handle the NNTP connection timeout in my code
am 08.02.2007 18:42:31 von boyd
In article <1170928309.001111.249450@v33g2000cwv.googlegroups.com>,
"Naren" wrote:
> Hi All,
> I have a perl script that use cpan NNTP.pm perl module for NNTP
> connection. I am passing the timeout as one parameter while opening
> the NNTP connection. I am intentionally timing out the NNTP
> connection. When I open the connection in debug mode, then I could see
> my connection is timing out. My question is how do I capture this
> timing out error in my code.
>
> Any suggesstion would be aprreciated.
in perldoc perlipc, you can see an example of how to force a timeout
outside the NNTP module. It would be something like this:
eval{
local $SIG{ALRM} = sub{die "timed out"};
alarm $timeout_secs;
# code goes here for your NNTP connection -leave out the timeout
alarm 0; # cancel the alarm if it gets here before timeout
};
if( $@ and $@ =~ /timed out/){
print "The NNTP connection timed out\n";
}
Boyd