Need to handle the NNTP connection timeout in my code

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.
Naren [ Do, 08 Februar 2007 10:51 ] [ ID #1623503 ]

Re: Need to handle the NNTP connection timeout in my code

In article <1170928309.001111.249450 [at] v33g2000cwv.googlegroups.com>,
"Naren" <naren.sarkar [at] 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( $ [at] and $ [at] =~ /timed out/){
print "The NNTP connection timed out\n";
}

Boyd
boyd [ Do, 08 Februar 2007 18:42 ] [ ID #1623505 ]
Perl » comp.lang.perl.modules » Need to handle the NNTP connection timeout in my code

Vorheriges Thema: system return value?
Nächstes Thema: HTML-Parser-3.56 build problem