Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Net::NNTP ping?

by robobunny (Friar)
on Dec 30, 2003 at 16:15 UTC ( #317703=note: print w/replies, xml ) Need Help??

in reply to Net::NNTP ping?

Haven't tested it, but you might be able to get away with checking the response from the 'date' call, which is supposed to give you the time on the news server. It seems like the most minimal call you can make, anyhow.

Replies are listed 'Best First'.
Re: Re: Net::NNTP ping?
by akis (Novice) on Dec 31, 2003 at 10:56 UTC
    Yes, I have tried out the date() method. Although it is part of the rfc, I do not think all servers support it. I've tried it on my private server, which runs leafnode, and it returns undef no matter if I am connected or not. Sample output as follows:
    $ perl -MNet::NNTP -MSocket -e '$n=Net::NNTP->new(localhost,Port=>1199 +,Timeout=>10,Debug=>1);print $n->date()||"undef"' Net::NNTP>>> Net::NNTP(2.22) Net::NNTP>>> Net::Cmd(2.24) Net::NNTP>>> Exporter(5.562) Net::NNTP>>> IO::Socket::INET(1.25) Net::NNTP>>> IO::Socket(1.26) Net::NNTP>>> IO::Handle(1.21) Net::NNTP=GLOB(0x826b0b0)<<< 200 Leafnode NNTP Daemon, version 1.9.31. +rel running at localhost (my fqdn: Net::NNTP=GLOB(0x826b0b0)>>> MODE READER Net::NNTP=GLOB(0x826b0b0)<<< 200 Leafnode 1.9.31.rel, pleased to meet +you! Net::NNTP=GLOB(0x826b0b0)>>> DATE Net::NNTP=GLOB(0x826b0b0)<<< 500 Unknown command Net::NNTP=GLOB(0x826b0b0)>>> QUIT Net::NNTP=GLOB(0x826b0b0)<<< 205 Always happy to serve! undef ^- output
      That's unforunate. I haven't used Net::NNTP, but with News::NNTPClient, I've used the help() call to check to see if I'm still connected. help also seems to be something that not all servers implement, but if your server has it, and you can run it from Net::NNTP, that might be an option. It probably has a lot more overhead than a simple date call though, especially if the server is actually trying to give you some useful information.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://317703]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2023-12-11 22:44 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (41 votes). Check out past polls.