Tim Skirvin > newslib > Net::NNTP::Client

Download:
newslib-0.84.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.6   Source  

NAME ^

Net::NNTP::Client - a module to simulate an entire NNTP client

SYNOPSIS ^

  use Net::NNTP::Client;
  my $client = new Net::NNTP::Client('news.cso.uiuc.edu',
        'server' => 'news.cso.uiuc.edu',  'port' => 119,
        'user'   => 'guest',              'pass' => 'guest' );

See below for the list of functions.

DESCRIPTION ^

Net::NNTP is a module designed to provide a common interface to NNTP servers. This module is an extension of this; it contains a Net::NNTP reference, in addition to various cached information about the server and enough information to reconnect again in the case of a hang-up.

METHODS ^

new ( NAME [, OPTIONS] )

Creates a new object and returns it. NAME is mandatory, and is the name of the connection, as well as (by default) the server name. OPTIONS is a list of key/value pairs; the useful keys are:

name, server, port, user, pass, debug, timeout

Each of these can be modified with its corresponding function.

name ( [NAME] )

Returns the name of the object. If NAME is passed, then it sets the name to its value.

server ( [SERVER] )

Returns the NNTP server name that the object will connect to. If SERVER is passed, then it sets the server name to its value.

port ( [PORT] )

Returns the TCP port number that the object will communicate with. If PORT is passed, then the port number is set to its value.

user ( [USER] )

Returns the user name that the object will authenticate itself to the NNTP server with. If USER is passed, then the user name is set to its value.

pass ( [PASS] )

Returns the password that the object will authenticate itself to the NNTP server with. If PASS is passed, then the password is set to its value.

debug ( [DEBUG] )

Returns true if we should print debugging information from the NNTP connection. Can be set with DEBUG.

timeout ( [TIMEOUT] )

Returns the timeout value of the NNTP connection. Defaults to 120. Can be set with TIMEOUT.

connect ()
reconnect ()
nntp ()

These three functions create the socket connection to an NNTP server. The connection is made to the server found by server() and the port at port(). If the connection is already open, then it returns that connection; otherwise, it reconnects and continues. Either way, if user() and pass() are set, then it authenticates as well.

disconnect ()

Disconnect from the NNTP server.

connected ()

If the object is currently connected to the NNTP server, returns 1; otherwise, returns 0.

load ( ITEM [, ARGS] )

Loads ITEM from the NNTP server, which is one of active, active.times, newsgroups, or overview.fmt. ARGS is the list of arguments to be passed into the appropriate NNTP call (see the Net::NNTP manual pages for active(), active_times(), newsgroups(), and overview_fmt() for details). These items are cached; if no arguments are passed in ARGS, then this value will be returned instead of fetching new information from the server.

Net::NNTP Methods

The following methods from Net::NNTP are directly implemented by this object. The real difference is that they will all try to reconnect to the server before running themselves; if this fail, then they return undef. Refer to Net::NNTP for details on how to use them.

article, head, body, nntpstat, group, ihave, last, date, postok, authinfo, newgroups, newnews, next, post, slave, quit, distributions, subscriptions, xgtitle, xhdr, xover, xpath, xpat, xrover, listgroup

Also, these functions have been re-implemented with load().

active, active_times, newsgroups, overview_fmt, list

And quit() has been re-implemented with disconnect().

REQUIREMENTS ^

Requires Net::NNTP.

NOTES ^

If you hadn't noticed, the real point of this is that this can be used in the place of Net::NNTP in a lot of situations. It doesn't offer too many advantages above it, though. Oh well.

SEE ALSO ^

Net::NNTP::Proxy, newsproxy.pl, Net::NNTP, News::NNTPAuth

TODO ^

The caching done by load() isn't all that hot. I'm not sure of its robustness for reconnections yet.

AUTHOR ^

Written by Tim Skirvin <tskirvin@killfile.org>.

COPYRIGHT ^

Copyright 2000 by Tim Skirvin <tskirvin@killfile.org>. This code may be redistributed under the same terms as Perl itself.

syntax highlighting: