Net::NNTP - NNTP Client class
use Net::NNTP;
$nntp = Net::NNTP->new("some.host.name");
$nntp->quit;
Net::NNTP
is a class implementing a simple NNTP client in Perl as described in RFC977. Net::NNTP
inherits its communication methods from Net::Cmd
This is the constructor for a new Net::NNTP object. HOST
is the name of the remote host to which a NNTP connection is required. If not given then it may be passed as the Host
option described below. If no host is passed then two environment variables are checked, first NNTPSERVER
then NEWSHOST
, then Net::Config
is checked, and if a host is not found then news
is used.
OPTIONS
are passed in a hash like fashion, using key and value pairs. Possible options are:
Host - NNTP host to connect to. It may be a single scalar, as defined for the PeerAddr
option in IO::Socket::INET, or a reference to an array with hosts to try in turn. The "host" method will return the value which was used to connect to the host.
Timeout - Maximum time, in seconds, to wait for a response from the NNTP server, a value of zero will cause all IO operations to block. (default: 120)
Debug - Enable the printing of debugging information to STDERR
Reader - If the remote server is INN then initially the connection will be to nnrpd, by default Net::NNTP
will issue a MODE READER
command so that the remote server becomes innd. If the Reader
option is given with a value of zero, then this command will not be sent and the connection will be left talking to nnrpd.
Unless otherwise stated all methods return either a true or false value, with true meaning that the operation was a success. When a method states that it returns a value, failure will be returned as undef or an empty list.
Retrieve the header, a blank line, then the body (text) of the specified article.
If FH
is specified then it is expected to be a valid filehandle and the result will be printed to it, on success a true value will be returned. If FH
is not specified then the return value, on success, will be a reference to an array containg the article requested, each entry in the array will contain one line of the article.
If no arguments are passed then the current article in the currently selected newsgroup is fetched.
MSGNUM
is a numeric id of an article in the current newsgroup, and will change the current article pointer. MSGID
is the message id of an article as shown in that article's header. It is anticipated that the client will obtain the MSGID
from a list provided by the newnews
command, from references contained within another article, or from the message-id provided in the response to some other commands.
If there is an error then undef
will be returned.
Like article
but only fetches the body of the article.
Like article
but only fetches the headers for the article.
These are similar to article(), body() and head(), but rather than returning the requested data directly, they return a tied filehandle from which to read the article.
The nntpstat
command is similar to the article
command except that no text is returned. When selecting by message number within a group, the nntpstat
command serves to set the "current article pointer" without sending text.
Using the nntpstat
command to select by message-id is valid but of questionable value, since a selection by message-id does not alter the "current article pointer".
Returns the message-id of the "current article".