.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::NNTP 3perl" .TH Net::NNTP 3perl 2024-05-30 "perl v5.38.2" "Perl Programmers Reference Guide" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Net::NNTP \- NNTP Client class .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Net::NNTP; \& \& $nntp = Net::NNTP\->new("some.host.name"); \& $nntp\->quit; \& \& # start with SSL, e.g. nntps \& $nntp = Net::NNTP\->new("some.host.name", SSL => 1); \& \& # start with plain and upgrade to SSL \& $nntp = Net::NNTP\->new("some.host.name"); \& $nntp\->starttls; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" \&\f(CW\*(C`Net::NNTP\*(C'\fR is a class implementing a simple NNTP client in Perl as described in RFC977 and RFC4642. With IO::Socket::SSL installed it also provides support for implicit and explicit TLS encryption, i.e. NNTPS or NNTP+STARTTLS. .PP The Net::NNTP class is a subclass of Net::Cmd and (depending on avaibility) of IO::Socket::IP, IO::Socket::INET6 or IO::Socket::INET. .SS "Class Methods" .IX Subsection "Class Methods" .ie n .IP """new([$host][, %options])""" 4 .el .IP "\f(CWnew([$host][, %options])\fR" 4 .IX Item "new([$host][, %options])" This is the constructor for a new Net::NNTP object. \f(CW$host\fR is the name of the remote host to which a NNTP connection is required. If not given then it may be passed as the \f(CW\*(C`Host\*(C'\fR option described below. If no host is passed then two environment variables are checked, first \f(CW\*(C`NNTPSERVER\*(C'\fR then \&\f(CW\*(C`NEWSHOST\*(C'\fR, then \f(CW\*(C`Net::Config\*(C'\fR is checked, and if a host is not found then \f(CW\*(C`news\*(C'\fR is used. .Sp \&\f(CW%options\fR are passed in a hash like fashion, using key and value pairs. Possible options are: .Sp \&\fBHost\fR \- NNTP host to connect to. It may be a single scalar, as defined for the \f(CW\*(C`PeerAddr\*(C'\fR 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. .Sp \&\fBPort\fR \- port to connect to. Default \- 119 for plain NNTP and 563 for immediate SSL (nntps). .Sp \&\fBSSL\fR \- If the connection should be done from start with SSL, contrary to later upgrade with \f(CW\*(C`starttls\*(C'\fR. You can use SSL arguments as documented in IO::Socket::SSL, but it will usually use the right arguments already. .Sp \&\fBTimeout\fR \- 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) .Sp \&\fBDebug\fR \- Enable the printing of debugging information to STDERR .Sp \&\fBReader\fR \- If the remote server is INN then initially the connection will be to innd, by default \f(CW\*(C`Net::NNTP\*(C'\fR will issue a \f(CW\*(C`MODE READER\*(C'\fR command so that the remote server becomes nnrpd. If the \f(CW\*(C`Reader\*(C'\fR option is given with a value of zero, then this command will not be sent and the connection will be left talking to innd. .Sp \&\fBLocalAddr\fR and \fBLocalPort\fR \- These parameters are passed directly to IO::Socket to allow binding the socket to a specific local address and port. .Sp \&\fBDomain\fR \- This parameter is passed directly to IO::Socket and makes it possible to enforce IPv4 connections even if IO::Socket::IP is used as super class. Alternatively \fBFamily\fR can be used. .SS "Object Methods" .IX Subsection "Object Methods" Unless otherwise stated all methods return either a \fItrue\fR or \fIfalse\fR value, with \fItrue\fR meaning that the operation was a success. When a method states that it returns a value, failure will be returned as \fIundef\fR or an empty list. .PP \&\f(CW\*(C`Net::NNTP\*(C'\fR inherits from \f(CW\*(C`Net::Cmd\*(C'\fR so methods defined in \f(CW\*(C`Net::Cmd\*(C'\fR may be used to send commands to the remote NNTP server in addition to the methods documented here. .ie n .IP host() 4 .el .IP \f(CWhost()\fR 4 .IX Item "host()" Returns the value used by the constructor, and passed to IO::Socket::INET, to connect to the host. .ie n .IP starttls() 4 .el .IP \f(CWstarttls()\fR 4 .IX Item "starttls()" Upgrade existing plain connection to SSL. Any arguments necessary for SSL must be given in \f(CW\*(C`new\*(C'\fR already. .ie n .IP """article([{$msgid|$msgnum}[, $fh]])""" 4 .el .IP "\f(CWarticle([{$msgid|$msgnum}[, $fh]])\fR" 4 .IX Item "article([{$msgid|$msgnum}[, $fh]])" Retrieve the header, a blank line, then the body (text) of the specified article. .Sp If \f(CW$fh\fR 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 \f(CW$fh\fR is not specified then the return value, on success, will be a reference to an array containing the article requested, each entry in the array will contain one line of the article. .Sp If no arguments are passed then the current article in the currently selected newsgroup is fetched. .Sp \&\f(CW$msgnum\fR is a numeric id of an article in the current newsgroup, and will change the current article pointer. \f(CW$msgid\fR is the message id of an article as shown in that article's header. It is anticipated that the client will obtain the \f(CW$msgid\fR from a list provided by the \f(CW\*(C`newnews\*(C'\fR command, from references contained within another article, or from the message-id provided in the response to some other commands. .Sp If there is an error then \f(CW\*(C`undef\*(C'\fR will be returned. .ie n .IP """body([{$msgid|$msgnum}[, [$fh]])""" 4 .el .IP "\f(CWbody([{$msgid|$msgnum}[, [$fh]])\fR" 4 .IX Item "body([{$msgid|$msgnum}[, [$fh]])" Like \f(CW\*(C`article\*(C'\fR but only fetches the body of the article. .ie n .IP """head([{$msgid|$msgnum}[, [$fh]])""" 4 .el .IP "\f(CWhead([{$msgid|$msgnum}[, [$fh]])\fR" 4 .IX Item "head([{$msgid|$msgnum}[, [$fh]])" Like \f(CW\*(C`article\*(C'\fR but only fetches the headers for the article. .ie n .IP articlefh([{$msgid|$msgnum}]) 4 .el .IP \f(CWarticlefh([{$msgid|$msgnum}])\fR 4 .IX Item "articlefh([{$msgid|$msgnum}])" .PD 0 .ie n .IP bodyfh([{$msgid|$msgnum}]) 4 .el .IP \f(CWbodyfh([{$msgid|$msgnum}])\fR 4 .IX Item "bodyfh([{$msgid|$msgnum}])" .ie n .IP headfh([{$msgid|$msgnum}]) 4 .el .IP \f(CWheadfh([{$msgid|$msgnum}])\fR 4 .IX Item "headfh([{$msgid|$msgnum}])" .PD These are similar to \fBarticle()\fR, \fBbody()\fR and \fBhead()\fR, but rather than returning the requested data directly, they return a tied filehandle from which to read the article. .ie n .IP nntpstat([{$msgid|$msgnum}]) 4 .el .IP \f(CWnntpstat([{$msgid|$msgnum}])\fR 4 .IX Item "nntpstat([{$msgid|$msgnum}])" The \f(CW\*(C`nntpstat\*(C'\fR command is similar to the \f(CW\*(C`article\*(C'\fR command except that no text is returned. When selecting by message number within a group, the \f(CW\*(C`nntpstat\*(C'\fR command serves to set the "current article pointer" without sending text. .Sp Using the \f(CW\*(C`nntpstat\*(C'\fR command to select by message-id is valid but of questionable value, since a selection by message-id does \fBnot\fR alter the "current article pointer". .Sp Returns the message-id of the "current article". .ie n .IP group([$group]) 4 .el .IP \f(CWgroup([$group])\fR 4 .IX Item "group([$group])" Set and/or get the current group. If \f(CW$group\fR is not given then information is returned on the current group. .Sp In a scalar context it returns the group name. .Sp 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. .ie n .IP help() 4 .el .IP \f(CWhelp()\fR 4 .IX Item "help()" Request help text (a short summary of commands that are understood by this implementation) from the server. Returns the text or undef upon failure. .ie n .IP """ihave($msgid[, $message])""" 4 .el .IP "\f(CWihave($msgid[, $message])\fR" 4 .IX Item "ihave($msgid[, $message])" The \f(CW\*(C`ihave\*(C'\fR command informs the server that the client has an article whose id is \f(CW$msgid\fR. If the server desires a copy of that article and \f(CW$message\fR has been given then it will be sent. .Sp Returns \fItrue\fR if the server desires the article and \f(CW$message\fR was successfully sent, if specified. .Sp If \f(CW$message\fR is not specified then the message must be sent using the \&\f(CW\*(C`datasend\*(C'\fR and \f(CW\*(C`dataend\*(C'\fR methods from Net::Cmd .Sp \&\f(CW$message\fR can be either an array of lines or a reference to an array and must be encoded by the caller to octets of whatever encoding is required, e.g. by using the Encode module's \f(CWencode()\fR function. .ie n .IP last() 4 .el .IP \f(CWlast()\fR 4 .IX Item "last()" Set the "current article pointer" to the previous article in the current newsgroup. .Sp Returns the message-id of the article. .ie n .IP date() 4 .el .IP \f(CWdate()\fR 4 .IX Item "date()" Returns the date on the remote server. This date will be in a UNIX time format (seconds since 1970) .ie n .IP postok() 4 .el .IP \f(CWpostok()\fR 4 .IX Item "postok()" \&\f(CW\*(C`postok\*(C'\fR will return \fItrue\fR if the servers initial response indicated that it will allow posting. .ie n .IP """authinfo($user, $pass)""" 4 .el .IP "\f(CWauthinfo($user, $pass)\fR" 4 .IX Item "authinfo($user, $pass)" Authenticates to the server (using the original AUTHINFO USER / AUTHINFO PASS form, defined in RFC2980) 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. .ie n .IP """authinfo_simple($user, $pass)""" 4 .el .IP "\f(CWauthinfo_simple($user, $pass)\fR" 4 .IX Item "authinfo_simple($user, $pass)" Authenticates to the server (using the proposed NNTP V2 AUTHINFO SIMPLE form, defined and deprecated in RFC2980) using the supplied username and password. As with "authinfo" the password is sent in clear text. .ie n .IP list() 4 .el .IP \f(CWlist()\fR 4 .IX Item "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. 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. .ie n .IP """newgroups($since[, $distributions])""" 4 .el .IP "\f(CWnewgroups($since[, $distributions])\fR" 4 .IX Item "newgroups($since[, $distributions])" \&\f(CW$since\fR is a time value and \f(CW$distributions\fR is either a distribution pattern or a reference to a list of distribution patterns. The result is the same as \f(CW\*(C`list\*(C'\fR, but the groups return will be limited to those created after \f(CW$since\fR and, if specified, in one of the distribution areas in \f(CW$distributions\fR. .ie n .IP """newnews($since[, $groups[, $distributions]])""" 4 .el .IP "\f(CWnewnews($since[, $groups[, $distributions]])\fR" 4 .IX Item "newnews($since[, $groups[, $distributions]])" \&\f(CW$since\fR is a time value. \f(CW$groups\fR is either a group pattern or a reference to a list of group patterns. \f(CW$distributions\fR is either a distribution pattern or a reference to a list of distribution patterns. .Sp Returns a reference to a list which contains the message-ids of all news posted after \f(CW$since\fR, that are in a groups which matched \f(CW$groups\fR and a distribution which matches \f(CW$distributions\fR. .ie n .IP next() 4 .el .IP \f(CWnext()\fR 4 .IX Item "next()" Set the "current article pointer" to the next article in the current newsgroup. .Sp Returns the message-id of the article. .ie n .IP post([$message]) 4 .el .IP \f(CWpost([$message])\fR 4 .IX Item "post([$message])" Post a new article to the news server. If \f(CW$message\fR is specified and posting is allowed then the message will be sent. .Sp If \f(CW$message\fR is not specified then the message must be sent using the \&\f(CW\*(C`datasend\*(C'\fR and \f(CW\*(C`dataend\*(C'\fR methods from Net::Cmd .Sp \&\f(CW$message\fR can be either an array of lines or a reference to an array and must be encoded by the caller to octets of whatever encoding is required, e.g. by using the Encode module's \f(CWencode()\fR function. .Sp The message, either sent via \f(CW\*(C`datasend\*(C'\fR or as the \f(CW$message\fR parameter, must be in the format as described by RFC822 and must contain From:, Newsgroups: and Subject: headers. .ie n .IP postfh() 4 .el .IP \f(CWpostfh()\fR 4 .IX Item "postfh()" Post a new article to the news server using a tied filehandle. If posting is allowed, this method will return a tied filehandle that you can \fBprint()\fR the contents of the article to be posted. You must explicitly \fBclose()\fR the filehandle when you are finished posting the article, and the return value from the \fBclose()\fR call will indicate whether the message was successfully posted. .ie n .IP slave() 4 .el .IP \f(CWslave()\fR 4 .IX Item "slave()" Tell the remote server that I am not a user client, but probably another news server. .ie n .IP quit() 4 .el .IP \f(CWquit()\fR 4 .IX Item "quit()" Quit the remote server and close the socket connection. .ie n .IP can_inet6() 4 .el .IP \f(CWcan_inet6()\fR 4 .IX Item "can_inet6()" Returns whether we can use IPv6. .ie n .IP can_ssl() 4 .el .IP \f(CWcan_ssl()\fR 4 .IX Item "can_ssl()" Returns whether we can use SSL. .SS "Extension Methods" .IX Subsection "Extension Methods" These methods use commands that are not part of the RFC977 documentation. Some servers may not support all of them. .ie n .IP newsgroups([$pattern]) 4 .el .IP \f(CWnewsgroups([$pattern])\fR 4 .IX Item "newsgroups([$pattern])" Returns a reference to a hash where the keys are all the group names which match \f(CW$pattern\fR, or all of the groups if no pattern is specified, and each value contains the description text for the group. .ie n .IP distributions() 4 .el .IP \f(CWdistributions()\fR 4 .IX Item "distributions()" Returns a reference to a hash where the keys are all the possible distribution names and the values are the distribution descriptions. .ie n .IP distribution_patterns() 4 .el .IP \f(CWdistribution_patterns()\fR 4 .IX Item "distribution_patterns()" Returns a reference to an array where each element, itself an array reference, consists of the three fields of a line of the distrib.pats list maintained by some NNTP servers, namely: a weight, a wildmat and a value which the client may use to construct a Distribution header. .ie n .IP subscriptions() 4 .el .IP \f(CWsubscriptions()\fR 4 .IX Item "subscriptions()" Returns a reference to a list which contains a list of groups which are recommended for a new user to subscribe to. .ie n .IP overview_fmt() 4 .el .IP \f(CWoverview_fmt()\fR 4 .IX Item "overview_fmt()" Returns a reference to an array which contain the names of the fields returned by \f(CW\*(C`xover\*(C'\fR. .ie n .IP active_times() 4 .el .IP \f(CWactive_times()\fR 4 .IX Item "active_times()" Returns a reference to a hash where the keys are the group names and each value is a reference to an array containing the time the groups was created and an identifier, possibly an Email address, of the creator. .ie n .IP active([$pattern]) 4 .el .IP \f(CWactive([$pattern])\fR 4 .IX Item "active([$pattern])" Similar to \f(CW\*(C`list\*(C'\fR but only active groups that match the pattern are returned. \&\f(CW$pattern\fR can be a group pattern. .ie n .IP xgtitle($pattern) 4 .el .IP \f(CWxgtitle($pattern)\fR 4 .IX Item "xgtitle($pattern)" Returns a reference to a hash where the keys are all the group names which match \f(CW$pattern\fR and each value is the description text for the group. .ie n .IP """xhdr($header, $message_spec)""" 4 .el .IP "\f(CWxhdr($header, $message_spec)\fR" 4 .IX Item "xhdr($header, $message_spec)" Obtain the header field \f(CW$header\fR for all the messages specified. .Sp The return value will be a reference to a hash where the keys are the message numbers and each value contains the text of the requested header for that message. .ie n .IP xover($message_spec) 4 .el .IP \f(CWxover($message_spec)\fR 4 .IX Item "xover($message_spec)" The return value will be a reference to a hash where the keys are the message numbers and each value contains a reference to an array which contains the overview fields for that message. .Sp The names of the fields can be obtained by calling \f(CW\*(C`overview_fmt\*(C'\fR. .ie n .IP xpath($message_id) 4 .el .IP \f(CWxpath($message_id)\fR 4 .IX Item "xpath($message_id)" Returns the path name to the file on the server which contains the specified message. .ie n .IP """xpat($header, $pattern, $message_spec)""" 4 .el .IP "\f(CWxpat($header, $pattern, $message_spec)\fR" 4 .IX Item "xpat($header, $pattern, $message_spec)" The result is the same as \f(CW\*(C`xhdr\*(C'\fR except the is will be restricted to headers where the text of the header matches \f(CW$pattern\fR .ie n .IP xrover($message_spec) 4 .el .IP \f(CWxrover($message_spec)\fR 4 .IX Item "xrover($message_spec)" The XROVER command returns reference information for the article(s) specified. .Sp Returns a reference to a HASH where the keys are the message numbers and the values are the References: lines from the articles .ie n .IP listgroup([$group]) 4 .el .IP \f(CWlistgroup([$group])\fR 4 .IX Item "listgroup([$group])" Returns a reference to a list of all the active messages in \f(CW$group\fR, or the current group if \f(CW$group\fR is not specified. .ie n .IP reader() 4 .el .IP \f(CWreader()\fR 4 .IX Item "reader()" Tell the server that you are a reader and not another server. .Sp This is required by some servers. For example if you are connecting to an INN server and you have transfer permission your connection will be connected to the transfer daemon, not the NNTP daemon. Issuing this command will cause the transfer daemon to hand over control to the NNTP daemon. .Sp Some servers do not understand this command, but issuing it and ignoring the response is harmless. .SS Unsupported .IX Subsection "Unsupported" The following NNTP command are unsupported by the package, and there are no plans to do so. .PP .Vb 4 \& AUTHINFO GENERIC \& XTHREAD \& XSEARCH \& XINDEX .Ve .SS Definitions .IX Subsection "Definitions" .ie n .IP $message_spec 4 .el .IP \f(CW$message_spec\fR 4 .IX Item "$message_spec" \&\f(CW$message_spec\fR is either a single message-id, a single message number, or a reference to a list of two message numbers. .Sp If \f(CW$message_spec\fR is a reference to a list of 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. .Sp \&\fBNOTE\fR For compatibility reasons only with earlier versions of Net::NNTP a message spec can be passed as a list of two numbers, this is deprecated and a reference to the list should now be passed .ie n .IP $pattern 4 .el .IP \f(CW$pattern\fR 4 .IX Item "$pattern" The \f(CW\*(C`NNTP\*(C'\fR protocol uses the \f(CW\*(C`WILDMAT\*(C'\fR format for patterns. The WILDMAT format was first developed by Rich Salz based on the format used in the UNIX "find" command to articulate file names. It was developed to provide a uniform mechanism for matching patterns in the same manner that the UNIX shell matches filenames. .Sp Patterns are implicitly anchored at the beginning and end of each string when testing for a match. .Sp There are five pattern matching operations other than a strict one-to-one match between the pattern and the source to be checked for a match. .Sp The first is an asterisk \f(CW\*(C`*\*(C'\fR to match any sequence of zero or more characters. .Sp The second is a question mark \f(CW\*(C`?\*(C'\fR to match any single character. The third specifies a specific set of characters. .Sp The set is specified as a list of characters, or as a range of characters where the beginning and end of the range are separated by a minus (or dash) character, or as any combination of lists and ranges. The dash can also be included in the set as a character it if is the beginning or end of the set. This set is enclosed in square brackets. The close square bracket \f(CW\*(C`]\*(C'\fR may be used in a set if it is the first character in the set. .Sp The fourth operation is the same as the logical not of the third operation and is specified the same way as the third with the addition of a caret character \f(CW\*(C`^\*(C'\fR at the beginning of the test string just inside the open square bracket. .Sp The final operation uses the backslash character to invalidate the special meaning of an open square bracket \f(CW\*(C`[\*(C'\fR, the asterisk, backslash or the question mark. Two backslashes in sequence will result in the evaluation of the backslash as a character with no special meaning. .RS 4 .IP Examples 4 .IX Item "Examples" .PD 0 .ie n .IP """[^]\-]""" 4 .el .IP \f(CW[^]\-]\fR 4 .IX Item "[^]-]" .PD matches any single character other than a close square bracket or a minus sign/dash. .ie n .IP *bdc 4 .el .IP \f(CW*bdc\fR 4 .IX Item "*bdc" matches any string that ends with the string "bdc" including the string "bdc" (without quotes). .ie n .IP """[0\-9a\-zA\-Z]""" 4 .el .IP \f(CW[0\-9a\-zA\-Z]\fR 4 .IX Item "[0-9a-zA-Z]" matches any single printable alphanumeric ASCII character. .ie n .IP """a??d""" 4 .el .IP \f(CWa??d\fR 4 .IX Item "a??d" matches any four character string which begins with a and ends with d. .RE .RS 4 .RE .SH EXPORTS .IX Header "EXPORTS" \&\fINone\fR. .SH "KNOWN BUGS" .IX Header "KNOWN BUGS" See . .SH "SEE ALSO" .IX Header "SEE ALSO" Net::Cmd, IO::Socket::SSL. .SH AUTHOR .IX Header "AUTHOR" Graham Barr >. .PP Steve Hay > is now maintaining libnet as of version 1.22_02. .SH COPYRIGHT .IX Header "COPYRIGHT" Copyright (C) 1995\-1997 Graham Barr. All rights reserved. .PP Copyright (C) 2013\-2016, 2020 Steve Hay. All rights reserved. .SH LICENCE .IX Header "LICENCE" This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself, i.e. under the terms of either the GNU General Public License or the Artistic License, as specified in the \fILICENCE\fR file. .SH VERSION .IX Header "VERSION" Version 3.15 .SH DATE .IX Header "DATE" 20 March 2023 .SH HISTORY .IX Header "HISTORY" See the \fIChanges\fR file.