nntp.html
来自「perl教程」· HTML 代码 · 共 605 行 · 第 1/2 页
HTML
605 行
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>Net::NNTP - NNTP Client class</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>
<body>
<script>writelinks('__top__',2);</script>
<h1><a>Net::NNTP - NNTP Client class</a></h1>
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#constructor">CONSTRUCTOR</a></li>
<li><a href="#methods">METHODS</a></li>
<ul>
<li><a href="#extension_methods">Extension methods</a></li>
</ul>
<li><a href="#unsupported">UNSUPPORTED</a></li>
<li><a href="#definitions">DEFINITIONS</a></li>
<li><a href="#see_also">SEE ALSO</a></li>
<li><a href="#author">AUTHOR</a></li>
<li><a href="#copyright">COPYRIGHT</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Net::NNTP - NNTP Client class</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
<span class="keyword">use</span> <span class="variable">Net::NNTP</span><span class="operator">;</span>
</pre>
<pre>
<span class="variable">$nntp</span> <span class="operator">=</span> <span class="variable">Net::NNTP</span><span class="operator">-></span><span class="variable">new</span><span class="operator">(</span><span class="string">"some.host.name"</span><span class="operator">);</span>
<span class="variable">$nntp</span><span class="operator">-></span><span class="variable">quit</span><span class="operator">;</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p><code>Net::NNTP</code> is a class implementing a simple NNTP client in Perl as described
in RFC977. <code>Net::NNTP</code> inherits its communication methods from <code>Net::Cmd</code></p>
<p>
</p>
<hr />
<h1><a name="constructor">CONSTRUCTOR</a></h1>
<dl>
<dt><strong><a name="item_new">new ( [ HOST ] [, OPTIONS ])</a></strong>
<dd>
<p>This is the constructor for a new Net::NNTP object. <code>HOST</code> is the
name of the remote host to which a NNTP connection is required. If not
given then it may be passed as the <code>Host</code> option described below. If no host is passed
then two environment variables are checked, first <code>NNTPSERVER</code> then
<code>NEWSHOST</code>, then <code>Net::Config</code> is checked, and if a host is not found
then <code>news</code> is used.</p>
</dd>
<dd>
<p><code>OPTIONS</code> are passed in a hash like fashion, using key and value pairs.
Possible options are:</p>
</dd>
<dd>
<p><strong>Host</strong> - NNTP host to connect to. It may be a single scalar, as defined for
the <code>PeerAddr</code> option in <a href="../../lib/IO/Socket/INET.html">the IO::Socket::INET manpage</a>, or a reference to
an array with hosts to try in turn. The <a href="#host">host</a> method will return the value
which was used to connect to the host.</p>
</dd>
<dd>
<p><strong>Timeout</strong> - 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)</p>
</dd>
<dd>
<p><strong>Debug</strong> - Enable the printing of debugging information to STDERR</p>
</dd>
<dd>
<p><strong>Reader</strong> - If the remote server is INN then initially the connection
will be to nnrpd, by default <code>Net::NNTP</code> will issue a <code>MODE READER</code> command
so that the remote server becomes innd. If the <code>Reader</code> option is given
with a value of zero, then this command will not be sent and the
connection will be left talking to nnrpd.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="methods">METHODS</a></h1>
<p>Unless otherwise stated all methods return either a <em>true</em> or <em>false</em>
value, with <em>true</em> meaning that the operation was a success. When a method
states that it returns a value, failure will be returned as <em>undef</em> or an
empty list.</p>
<dl>
<dt><strong><a name="item_article">article ( [ MSGID|MSGNUM ], [FH] )</a></strong>
<dd>
<p>Retrieve the header, a blank line, then the body (text) of the
specified article.</p>
</dd>
<dd>
<p>If <code>FH</code> 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 <code>FH</code> 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.</p>
</dd>
<dd>
<p>If no arguments are passed then the current article in the currently
selected newsgroup is fetched.</p>
</dd>
<dd>
<p><code>MSGNUM</code> is a numeric id of an article in the current newsgroup, and
will change the current article pointer. <code>MSGID</code> is the message id of
an article as shown in that article's header. It is anticipated that the
client will obtain the <code>MSGID</code> from a list provided by the <a href="#item_newnews"><code>newnews</code></a>
command, from references contained within another article, or from the
message-id provided in the response to some other commands.</p>
</dd>
<dd>
<p>If there is an error then <a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a> will be returned.</p>
</dd>
</li>
<dt><strong><a name="item_body">body ( [ MSGID|MSGNUM ], [FH] )</a></strong>
<dd>
<p>Like <a href="#item_article"><code>article</code></a> but only fetches the body of the article.</p>
</dd>
</li>
<dt><strong><a name="item_head">head ( [ MSGID|MSGNUM ], [FH] )</a></strong>
<dd>
<p>Like <a href="#item_article"><code>article</code></a> but only fetches the headers for the article.</p>
</dd>
</li>
<dt><strong><a name="item_articlefh">articlefh ( [ MSGID|MSGNUM ] )</a></strong>
<dt><strong><a name="item_bodyfh">bodyfh ( [ MSGID|MSGNUM ] )</a></strong>
<dt><strong><a name="item_headfh">headfh ( [ MSGID|MSGNUM ] )</a></strong>
<dd>
<p>These are similar to article(), <a href="#item_body"><code>body()</code></a> and head(), but rather than
returning the requested data directly, they return a tied filehandle
from which to read the article.</p>
</dd>
</li>
<dt><strong><a name="item_nntpstat">nntpstat ( [ MSGID|MSGNUM ] )</a></strong>
<dd>
<p>The <a href="#item_nntpstat"><code>nntpstat</code></a> command is similar to the <a href="#item_article"><code>article</code></a> command except that no
text is returned. When selecting by message number within a group,
the <a href="#item_nntpstat"><code>nntpstat</code></a> command serves to set the "current article pointer" without
sending text.</p>
</dd>
<dd>
<p>Using the <a href="#item_nntpstat"><code>nntpstat</code></a> command to
select by message-id is valid but of questionable value, since a
selection by message-id does <strong>not</strong> alter the "current article pointer".</p>
</dd>
<dd>
<p>Returns the message-id of the "current article".</p>
</dd>
</li>
<dt><strong><a name="item_group">group ( [ GROUP ] )</a></strong>
<dd>
<p>Set and/or get the current group. If <code>GROUP</code> is not given then information
is returned on the current group.</p>
</dd>
<dd>
<p>In a scalar context it returns the group name.</p>
</dd>
<dd>
<p>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.</p>
</dd>
</li>
<dt><strong><a name="item_ihave">ihave ( MSGID [, MESSAGE ])</a></strong>
<dd>
<p>The <a href="#item_ihave"><code>ihave</code></a> command informs the server that the client has an article
whose id is <code>MSGID</code>. If the server desires a copy of that
article, and <code>MESSAGE</code> has been given the it will be sent.</p>
</dd>
<dd>
<p>Returns <em>true</em> if the server desires the article and <code>MESSAGE</code> was
successfully sent,if specified.</p>
</dd>
<dd>
<p>If <code>MESSAGE</code> is not specified then the message must be sent using the
<code>datasend</code> and <code>dataend</code> methods from <a href="../../lib/Net/Cmd.html">the Net::Cmd manpage</a></p>
</dd>
<dd>
<p><code>MESSAGE</code> can be either an array of lines or a reference to an array.</p>
</dd>
</li>
<dt><strong><a name="item_last">last ()</a></strong>
<dd>
<p>Set the "current article pointer" to the previous article in the current
newsgroup.</p>
</dd>
<dd>
<p>Returns the message-id of the article.</p>
</dd>
</li>
<dt><strong><a name="item_date">date ()</a></strong>
<dd>
<p>Returns the date on the remote server. This date will be in a UNIX time
format (seconds since 1970)</p>
</dd>
</li>
<dt><strong><a name="item_postok">postok ()</a></strong>
<dd>
<p><a href="#item_postok"><code>postok</code></a> will return <em>true</em> if the servers initial response indicated
that it will allow posting.</p>
</dd>
</li>
<dt><strong><a name="item_authinfo">authinfo ( USER, PASS )</a></strong>
<dd>
<p>Authenticates to the server (using AUTHINFO USER / AUTHINFO PASS)
using the supplied username and password. Please note that the
password is sent in clear text to the server. This command should not
be used with valuable passwords unless the connection to the server is
somehow protected.</p>
</dd>
</li>
<dt><strong><a name="item_list">list ()</a></strong>
<dd>
<p>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. The elements in this array are:- the last article number in the group,
the first article number in the group and any information flags about the group.</p>
</dd>
</li>
<dt><strong><a name="item_newgroups">newgroups ( SINCE [, DISTRIBUTIONS ])</a></strong>
<dd>
<p><code>SINCE</code> is a time value and <code>DISTRIBUTIONS</code> is either a distribution
pattern or a reference to a list of distribution patterns.
The result is the same as <a href="#item_list"><code>list</code></a>, but the
groups return will be limited to those created after <code>SINCE</code> and, if
specified, in one of the distribution areas in <code>DISTRIBUTIONS</code>.</p>
</dd>
</li>
<dt><strong><a name="item_newnews">newnews ( SINCE [, GROUPS [, DISTRIBUTIONS ]])</a></strong>
<dd>
<p><code>SINCE</code> is a time value. <code>GROUPS</code> is either a group pattern or a reference
to a list of group patterns. <code>DISTRIBUTIONS</code> is either a distribution
pattern or a reference to a list of distribution patterns.</p>
</dd>
<dd>
<p>Returns a reference to a list which contains the message-ids of all news posted
after <code>SINCE</code>, that are in a groups which matched <code>GROUPS</code> and a
distribution which matches <code>DISTRIBUTIONS</code>.</p>
</dd>
</li>
<dt><strong><a name="item_next">next ()</a></strong>
<dd>
<p>Set the "current article pointer" to the next article in the current
newsgroup.</p>
</dd>
<dd>
<p>Returns the message-id of the article.</p>
</dd>
</li>
<dt><strong><a name="item_post">post ( [ MESSAGE ] )</a></strong>
<dd>
<p>Post a new article to the news server. If <code>MESSAGE</code> is specified and posting
is allowed then the message will be sent.</p>
</dd>
<dd>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?