For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > February 2007 > Need to handle the NNTP connection timeout in my code









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Need to handle the NNTP connection timeout in my code
Naren

2007-02-08, 3:58 am

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.

boyd

2007-02-08, 6:58 pm

In article <1170928309.001111.249450@v33g2000cwv.googlegroups.com>,
"Naren" <naren.sarkar@gmail.com> 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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com