{
    "mode": "info",
    "parameter": "Net::NNTP",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/Net%3A%3ANNTP/json",
    "generated": "2026-07-05T11:45:13Z",
    "synopsis": "use Net::NNTP;\n$nntp = Net::NNTP->new(\"some.host.name\");\n$nntp->quit;\n# start with SSL, e.g. nntps\n$nntp = Net::NNTP->new(\"some.host.name\", SSL => 1);\n# start with plain and upgrade to SSL\n$nntp = Net::NNTP->new(\"some.host.name\");\n$nntp->starttls;",
    "sections": {
        "NAME": {
            "content": "Net::NNTP - NNTP Client class\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Net::NNTP;\n\n$nntp = Net::NNTP->new(\"some.host.name\");\n$nntp->quit;\n\n# start with SSL, e.g. nntps\n$nntp = Net::NNTP->new(\"some.host.name\", SSL => 1);\n\n# start with plain and upgrade to SSL\n$nntp = Net::NNTP->new(\"some.host.name\");\n$nntp->starttls;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "\"Net::NNTP\" is a class implementing a simple NNTP client in Perl as\ndescribed in RFC977 and RFC4642.  With IO::Socket::SSL installed it\nalso provides support for implicit and explicit TLS encryption, i.e.\nNNTPS or NNTP+STARTTLS.\n\nThe Net::NNTP class is a subclass of Net::Cmd and (depending on\navaibility) of IO::Socket::IP, IO::Socket::INET6 or IO::Socket::INET.\n\nClass Methods\n\"new([$host][, %options])\"\nThis is the constructor for a new Net::NNTP object. $host is the\nname of the remote host to which a NNTP connection is required. If\nnot given then it may be passed as the \"Host\" option described\nbelow. If no host is passed then two environment variables are\nchecked, first \"NNTPSERVER\" then \"NEWSHOST\", then \"Net::Config\" is\nchecked, and if a host is not found then \"news\" is used.\n\n%options are passed in a hash like fashion, using key and value\npairs.  Possible options are:\n\nHost - NNTP host to connect to. It may be a single scalar, as\ndefined for the \"PeerAddr\" option in IO::Socket::INET, or a\nreference to an array with hosts to try in turn. The \"host\" method\nwill return the value which was used to connect to the host.\n\nPort - port to connect to.  Default - 119 for plain NNTP and 563\nfor immediate SSL (nntps).\n\nSSL - If the connection should be done from start with SSL,\ncontrary to later upgrade with \"starttls\".  You can use SSL\narguments as documented in IO::Socket::SSL, but it will usually use\nthe right arguments already.\n\nTimeout - Maximum time, in seconds, to wait for a response from the\nNNTP server, a value of zero will cause all IO operations to block.\n(default: 120)\n\nDebug - Enable the printing of debugging information to STDERR\n\nReader - If the remote server is INN then initially the connection\nwill be to innd, by default \"Net::NNTP\" will issue a \"MODE READER\"\ncommand so that the remote server becomes nnrpd. If the \"Reader\"\noption is given with a value of zero, then this command will not be\nsent and the connection will be left talking to innd.\n\nLocalAddr and LocalPort - These parameters are passed directly to\nIO::Socket to allow binding the socket to a specific local address\nand port.\n\nDomain - This parameter is passed directly to IO::Socket and makes\nit possible to enforce IPv4 connections even if IO::Socket::IP is\nused as super class. Alternatively Family can be used.\n\nObject Methods\nUnless otherwise stated all methods return either a true or false\nvalue, with true meaning that the operation was a success. When a\nmethod states that it returns a value, failure will be returned as\nundef or an empty list.\n\n\"Net::NNTP\" inherits from \"Net::Cmd\" so methods defined in \"Net::Cmd\"\nmay be used to send commands to the remote NNTP server in addition to\nthe methods documented here.\n\n\"host()\"\nReturns the value used by the constructor, and passed to\nIO::Socket::INET, to connect to the host.\n\n\"starttls()\"\nUpgrade existing plain connection to SSL.  Any arguments necessary\nfor SSL must be given in \"new\" already.\n\n\"article([{$msgid|$msgnum}[, $fh]])\"\nRetrieve the header, a blank line, then the body (text) of the\nspecified article.\n\nIf $fh is specified then it is expected to be a valid filehandle\nand the result will be printed to it, on success a true value will\nbe returned. If $fh is not specified then the return value, on\nsuccess, will be a reference to an array containing the article\nrequested, each entry in the array will contain one line of the\narticle.\n\nIf no arguments are passed then the current article in the\ncurrently selected newsgroup is fetched.\n\n$msgnum is a numeric id of an article in the current newsgroup, and\nwill change the current article pointer.  $msgid is the message id\nof an article as shown in that article's header.  It is anticipated\nthat the client will obtain the $msgid from a list provided by the\n\"newnews\" command, from references contained within another\narticle, or from the message-id provided in the response to some\nother commands.\n\nIf there is an error then \"undef\" will be returned.\n\n\"body([{$msgid|$msgnum}[, [$fh]])\"\nLike \"article\" but only fetches the body of the article.\n\n\"head([{$msgid|$msgnum}[, [$fh]])\"\nLike \"article\" but only fetches the headers for the article.\n\n\"articlefh([{$msgid|$msgnum}])\"\n\"bodyfh([{$msgid|$msgnum}])\"\n\"headfh([{$msgid|$msgnum}])\"\nThese are similar to article(), body() and head(), but rather than\nreturning the requested data directly, they return a tied\nfilehandle from which to read the article.\n\n\"nntpstat([{$msgid|$msgnum}])\"\nThe \"nntpstat\" command is similar to the \"article\" command except\nthat no text is returned.  When selecting by message number within\na group, the \"nntpstat\" command serves to set the \"current article\npointer\" without sending text.\n\nUsing the \"nntpstat\" command to select by message-id is valid but\nof questionable value, since a selection by message-id does not\nalter the \"current article pointer\".\n\nReturns the message-id of the \"current article\".\n\n\"group([$group])\"\nSet and/or get the current group. If $group is not given then\ninformation is returned on the current group.\n\nIn a scalar context it returns the group name.\n\nIn an array context the return value is a list containing, the\nnumber of articles in the group, the number of the first article,\nthe number of the last article and the group name.\n\n\"help()\"\nRequest help text (a short summary of commands that are understood\nby this implementation) from the server. Returns the text or undef\nupon failure.\n\n\"ihave($msgid[, $message])\"\nThe \"ihave\" command informs the server that the client has an\narticle whose id is $msgid.  If the server desires a copy of that\narticle and $message has been given then it will be sent.\n\nReturns true if the server desires the article and $message was\nsuccessfully sent, if specified.\n\nIf $message is not specified then the message must be sent using\nthe \"datasend\" and \"dataend\" methods from Net::Cmd\n\n$message can be either an array of lines or a reference to an array\nand must be encoded by the caller to octets of whatever encoding is\nrequired, e.g. by using the Encode module's \"encode()\" function.\n\n\"last()\"\nSet the \"current article pointer\" to the previous article in the\ncurrent newsgroup.\n\nReturns the message-id of the article.\n\n\"date()\"\nReturns the date on the remote server. This date will be in a UNIX\ntime format (seconds since 1970)\n\n\"postok()\"\n\"postok\" will return true if the servers initial response indicated\nthat it will allow posting.\n\n\"authinfo($user, $pass)\"\nAuthenticates to the server (using the original AUTHINFO USER /\nAUTHINFO PASS form, defined in RFC2980) using the supplied username\nand password.  Please note that the password is sent in clear text\nto the server.  This command should not be used with valuable\npasswords unless the connection to the server is somehow protected.\n\n\"authinfosimple($user, $pass)\"\nAuthenticates to the server (using the proposed NNTP V2 AUTHINFO\nSIMPLE form, defined and deprecated in RFC2980) using the supplied\nusername and password.  As with \"authinfo\" the password is sent in\nclear text.\n\n\"list()\"\nObtain information about all the active newsgroups. The results is\na reference to a hash where the key is a group name and each value\nis a reference to an array. The elements in this array are:- the\nlast article number in the group, the first article number in the\ngroup and any information flags about the group.\n\n\"newgroups($since[, $distributions])\"\n$since is a time value and $distributions is either a distribution\npattern or a reference to a list of distribution patterns.  The\nresult is the same as \"list\", but the groups return will be limited\nto those created after $since and, if specified, in one of the\ndistribution areas in $distributions.\n\n\"newnews($since[, $groups[, $distributions]])\"\n$since is a time value. $groups is either a group pattern or a\nreference to a list of group patterns. $distributions is either a\ndistribution pattern or a reference to a list of distribution\npatterns.\n\nReturns a reference to a list which contains the message-ids of all\nnews posted after $since, that are in a groups which matched\n$groups and a distribution which matches $distributions.\n\n\"next()\"\nSet the \"current article pointer\" to the next article in the\ncurrent newsgroup.\n\nReturns the message-id of the article.\n\n\"post([$message])\"\nPost a new article to the news server. If $message is specified and\nposting is allowed then the message will be sent.\n\nIf $message is not specified then the message must be sent using\nthe \"datasend\" and \"dataend\" methods from Net::Cmd\n\n$message can be either an array of lines or a reference to an array\nand must be encoded by the caller to octets of whatever encoding is\nrequired, e.g. by using the Encode module's \"encode()\" function.\n\nThe message, either sent via \"datasend\" or as the $message\nparameter, must be in the format as described by RFC822 and must\ncontain From:, Newsgroups: and Subject: headers.\n\n\"postfh()\"\nPost a new article to the news server using a tied filehandle.  If\nposting is allowed, this method will return a tied filehandle that\nyou can print() the contents of the article to be posted.  You must\nexplicitly close() the filehandle when you are finished posting the\narticle, and the return value from the close() call will indicate\nwhether the message was successfully posted.\n\n\"slave()\"\nTell the remote server that I am not a user client, but probably\nanother news server.\n\n\"quit()\"\nQuit the remote server and close the socket connection.\n\n\"caninet6()\"\nReturns whether we can use IPv6.\n\n\"canssl()\"\nReturns whether we can use SSL.\n\nExtension Methods\nThese methods use commands that are not part of the RFC977\ndocumentation. Some servers may not support all of them.\n\n\"newsgroups([$pattern])\"\nReturns a reference to a hash where the keys are all the group\nnames which match $pattern, or all of the groups if no pattern is\nspecified, and each value contains the description text for the\ngroup.\n\n\"distributions()\"\nReturns a reference to a hash where the keys are all the possible\ndistribution names and the values are the distribution\ndescriptions.\n\n\"distributionpatterns()\"\nReturns a reference to an array where each element, itself an array\nreference, consists of the three fields of a line of the\ndistrib.pats list maintained by some NNTP servers, namely: a\nweight, a wildmat and a value which the client may use to construct\na Distribution header.\n\n\"subscriptions()\"\nReturns a reference to a list which contains a list of groups which\nare recommended for a new user to subscribe to.\n\n\"overviewfmt()\"\nReturns a reference to an array which contain the names of the\nfields returned by \"xover\".\n\n\"activetimes()\"\nReturns a reference to a hash where the keys are the group names\nand each value is a reference to an array containing the time the\ngroups was created and an identifier, possibly an Email address, of\nthe creator.\n\n\"active([$pattern])\"\nSimilar to \"list\" but only active groups that match the pattern are\nreturned.  $pattern can be a group pattern.\n\n\"xgtitle($pattern)\"\nReturns a reference to a hash where the keys are all the group\nnames which match $pattern and each value is the description text\nfor the group.\n\n\"xhdr($header, $messagespec)\"\nObtain the header field $header for all the messages specified.\n\nThe return value will be a reference to a hash where the keys are\nthe message numbers and each value contains the text of the\nrequested header for that message.\n\n\"xover($messagespec)\"\nThe return value will be a reference to a hash where the keys are\nthe message numbers and each value contains a reference to an array\nwhich contains the overview fields for that message.\n\nThe names of the fields can be obtained by calling \"overviewfmt\".\n\n\"xpath($messageid)\"\nReturns the path name to the file on the server which contains the\nspecified message.\n\n\"xpat($header, $pattern, $messagespec)\"\nThe result is the same as \"xhdr\" except the is will be restricted\nto headers where the text of the header matches $pattern\n\n\"xrover($messagespec)\"\nThe XROVER command returns reference information for the article(s)\nspecified.\n\nReturns a reference to a HASH where the keys are the message\nnumbers and the values are the References: lines from the articles\n\n\"listgroup([$group])\"\nReturns a reference to a list of all the active messages in $group,\nor the current group if $group is not specified.\n\n\"reader()\"\nTell the server that you are a reader and not another server.\n\nThis is required by some servers. For example if you are connecting\nto an INN server and you have transfer permission your connection\nwill be connected to the transfer daemon, not the NNTP daemon.\nIssuing this command will cause the transfer daemon to hand over\ncontrol to the NNTP daemon.\n\nSome servers do not understand this command, but issuing it and\nignoring the response is harmless.\n\nUnsupported\nThe following NNTP command are unsupported by the package, and there\nare no plans to do so.\n\nAUTHINFO GENERIC\nXTHREAD\nXSEARCH\nXINDEX\n\nDefinitions\n$messagespec\n$messagespec is either a single message-id, a single message\nnumber, or a reference to a list of two message numbers.\n\nIf $messagespec is a reference to a list of two message numbers\nand the second number in a range is less than or equal to the first\nthen the range represents all messages in the group after the first\nmessage number.\n\nNOTE For compatibility reasons only with earlier versions of\nNet::NNTP a message spec can be passed as a list of two numbers,\nthis is deprecated and a reference to the list should now be passed\n\n$pattern\nThe \"NNTP\" protocol uses the \"WILDMAT\" format for patterns.  The\nWILDMAT format was first developed by Rich Salz based on the format\nused in the UNIX \"find\" command to articulate file names. It was\ndeveloped to provide a uniform mechanism for matching patterns in\nthe same manner that the UNIX shell matches filenames.\n\nPatterns are implicitly anchored at the beginning and end of each\nstring when testing for a match.\n\nThere are five pattern matching operations other than a strict one-\nto-one match between the pattern and the source to be checked for a\nmatch.\n\nThe first is an asterisk \"*\" to match any sequence of zero or more\ncharacters.\n\nThe second is a question mark \"?\" to match any single character.\nThe third specifies a specific set of characters.\n\nThe set is specified as a list of characters, or as a range of\ncharacters where the beginning and end of the range are separated\nby a minus (or dash) character, or as any combination of lists and\nranges. The dash can also be included in the set as a character it\nif is the beginning or end of the set. This set is enclosed in\nsquare brackets. The close square bracket \"]\" may be used in a set\nif it is the first character in the set.\n\nThe fourth operation is the same as the logical not of the third\noperation and is specified the same way as the third with the\naddition of a caret character \"^\" at the beginning of the test\nstring just inside the open square bracket.\n\nThe final operation uses the backslash character to invalidate the\nspecial meaning of an open square bracket \"[\", the asterisk,\nbackslash or the question mark. Two backslashes in sequence will\nresult in the evaluation of the backslash as a character with no\nspecial meaning.\n\nExamples\n\"[^]-]\"\nmatches any single character other than a close square bracket\nor a minus sign/dash.\n\n*bdc\nmatches any string that ends with the string \"bdc\" including\nthe string \"bdc\" (without quotes).\n\n\"[0-9a-zA-Z]\"\nmatches any single printable alphanumeric ASCII character.\n\n\"a??d\"\nmatches any four character string which begins with a and ends\nwith d.\n",
            "subsections": []
        },
        "EXPORTS": {
            "content": "None.\n",
            "subsections": []
        },
        "KNOWN BUGS": {
            "content": "See <https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=libnet>.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Net::Cmd, IO::Socket::SSL.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Graham Barr <gbarr@pobox.com <mailto:gbarr@pobox.com>>.\n\nSteve Hay <shay@cpan.org <mailto:shay@cpan.org>> is now maintaining\nlibnet as of version 1.2202.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (C) 1995-1997 Graham Barr.  All rights reserved.\n\nCopyright (C) 2013-2016, 2020 Steve Hay.  All rights reserved.\n",
            "subsections": []
        },
        "LICENCE": {
            "content": "This module is free software; you can redistribute it and/or modify it\nunder the same terms as Perl itself, i.e. under the terms of either the\nGNU General Public License or the Artistic License, as specified in the\nLICENCE file.\n",
            "subsections": []
        },
        "VERSION": {
            "content": "Version 3.13\n",
            "subsections": []
        },
        "DATE": {
            "content": "23 Dec 2020\n",
            "subsections": []
        },
        "HISTORY": {
            "content": "See the Changes file.\n\nperl v5.34.0                      2026-06-23                  Net::NNTP(3perl)",
            "subsections": []
        }
    },
    "summary": "Net::NNTP - NNTP Client class",
    "flags": [],
    "examples": [],
    "see_also": []
}