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: xxxx.client.attbi.com)
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
| [reply] [d/l] |
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.
| [reply] |