NAME
Net::NNTP - NNTP Client class
SYNOPSIS
use Net::NNTP;
$nntp = Net::NNTP->new("some.host.name");
$nntp->quit;
DESCRIPTION
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
CONSTRUCTOR
- new ( [ HOST [, OPTIONS ]])
-
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 thenews
is used.OPTIONS
are passed in a hash like fasion, using key and value pairs. Possible options are:Timeout - Maximum time, in seconds, to wait for a response from the NNTP server (default: 120)
Debug - Enable the printing of debugging information to STDERR
METHODS
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, falure will be returned as undef or an empty list.
- article ( [ MSGID|MSGNUM ] )
-
Retreive the header, a blank line, then the body (text) of the specified article.
If no arguments are passed then the current aricle in the current newsgroup is returned.
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 theMSGID
from a list provided by thenewnews
command, from references contained within another article, or from the message-id provided in the response to some other commands.Returns a reference to an array containing the article.
- body ( [ MSGID|MSGNUM ] )
-
Retreive the body (text) of the specified article.
Takes the same arguments as
article
Returns a reference to an array containing the body of the article.
- head ( [ MSGID|MSGNUM ] )
-
Retreive the header of the specified article.
Takes the same arguments as
article
Returns a reference to an array containing the header of the article.
- nntpstat ( [ MSGID|MSGNUM ] )
-
The
nntpstat
command is similar to thearticle
command except that no text is returned. When selecting by message number within a group, thenntpstat
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".
- group ( [ GROUP ] )
-
Set and/or get the current group. If
GROUP
is not given then information is returned on the current group.In a scalar context it returns the group name.
In an array context the return value is a list containing, the number of articles in the group, the number of the first article, the number of the last article and the group name.
- ihave ( MSGID [, MESSAGE])
-
The
ihave
command informs the server that the client has an article whose id isMSGID
. If the server desires a copy of that article, andMESSAGE
has been given the it will be sent.Returns true if the server desires the article and
MESSAGE
was successfully sent,if specified.If
MESSAGE
is not specified then the message must be sent using thedatasend
anddataend
methods from Net::CmdMESSAGE
can be either an array of lines or a reference to an array. - last ()
-
Set the "current article pointer" to the previous article in the current newsgroup.
Returns the message-id of the article.
- date ()
-
Returns the date on the remote server. This date will be in a UNIX time format (seconds since 1970)
- postok ()
-
postok
will return true if the servers initial response indicated that it will allow posting. - authinfo ( USER, PASS )
- list ()
-
Obtain information about all the active newsgroups. The results is a reference to a hash where the key is a group name and each value is a reference to an array which contains the first article number in the group, the last article number in the group and any informations flags about the group.
- newgroups ( SINCE [, DISTRIBUTIONS ])
-
SINCE
is a time value andDISTRIBUTIONS
is either a distribution pattern or a reference to a list of distribution patterns. The result is the same aslist
, but the groups return will be limited to those created afterSINCE
and, if specified, in one of the distribution areas inDISTRIBUTIONS
. - newnews ( SINCE [, GROUPS [, DISTRIBUTIONS ]])
-
SINCE
is a time value.GROUPS
is either a group pattern or a reference to a list of group patterns.DISTRIBUTIONS
is either a distribution pattern or a reference to a list of distribution patterns.Returns a reference to a list which contains the message-ids of all news posted after
SINCE
, that are in a groups which matchedGROUPS
and a distribution which matchesDISTRIBUTIONS
. - next ()
-
Set the "current article pointer" to the next article in the current newsgroup.
Returns the message-id of the article.
- post ( [ MESSAGE ] )
-
Post a new article to the news server. If
MESSAGE
is specified and posting is allowed then the message will be sent.If
MESSAGE
is not specified then the message must be sent using thedatasend
anddataend
methods from Net::CmdMESSAGE
can be either an array of lines or a reference to an array. - slave ()
-
Tell the remote server that I am not a user client, but probably another news server.
- quit ()
-
Quit the remote server and close the socket connection.
Extension methods
These methods use commands that are not part of the RFC977 documentation. Some servers may not support all of them.
- newsgroups ( [ PATTERN ] )
-
Returns a reference to a hash where the keys are all the group names which match
PATTERN
, or all of the groups if no pattern is specified, and each value contains the description text for the group. - distributions ()
-
Returns a reference to a hash where the keys are all the possible distribution names and the values are the distribution descriptions.
- subscriptions ()
-
Returns a reference to a list which contains a list of groups which are reccomended for a new user to subscribe to.
- overview_fmt ()
-
Returns a reference to an array which contain the names of the fields returnd by
xover
. - active_times ()
-
Returns a reference to a hash where the keys are the group names and each value is a reference to an array containg the time the groups was created and an identifier, possibly an Email address, of the creator.
- active ( [ PATTERN ] )
-
Similar to
list
but only active groups that match the pattern are returned.PATTERN
can be a group pattern. - xgtitle ( PATTERN )
-
Returns a reference to a hash where the keys are all the group names which match
PATTERN
and each value is the description text for the group. - xhdr ( HEADER, MESSAGE-RANGE )
-
Obtain the header field
HEADER
for all the messages specified.Returns a reference to a hash where the keys are the message numbers and each value contains the header for that message.
- xover ( MESSAGE-RANGE )
-
Returns a reference to a hash where the keys are the message numbers and each value is a reference to an array which contains the overview fields for that message. The names of these fields can be obtained by calling
overview_fmt
. - xpath ( MESSAGE-ID )
-
Returns the path name to the file on the server which contains the specified message.
- xpat ( HEADER, PATTERN, MESSAGE-RANGE)
-
The result is the same as
xhdr
except the is will be restricted to headers that matchPATTERN
DEFINITION
- MESSAGE-RANGE
-
MESSAGE-RANGE
is either a single message-id, a single mesage number, or two message numbers.If
MESSAGE-RANGE
is two message numbers and the second number in a range is less than or equal to the first then the range represents all messages in the group after the first message number.
SEE ALSO
AUTHOR
Graham Barr <Graham.Barr@tiuk.ti.com>
REVISION
$Revision: 2.0 $
COPYRIGHT
Copyright (c) 1995 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.