Net::NNTP
Inherits Net::NNTP::Commands::Auth < Net::NNTP::Commands::Extensions < Net::NNTP::Commands < Reference < Object
Net::NNTP
What is This Library?
This library provides functionality to retrieve and, or post Usenet news articles via NNTP, the Network News Transfer Protocol. The Usenet is a world-wide distributed discussion system. It consists of a set of "newsgroups" with names that are classified hierarchically by topic. "articles" or "messages" are "posted" to these newsgroups by people on computers with the appropriate software -- these articles are then broadcast to other interconnected NNTP servers via a wide variety of networks. For details of NNTP itself, see RFC977.
What is This Library NOT?
This library does NOT provide functions to compose Usenet news. You must create and, or format them yourself as per guidelines per Standard for Interchange of Usenet messages, see RFC850, RFC2047 and a fews other RFC's.
FYI: the official documentation on Usenet news extentions is: RFC2980.
Constants
The default NNTP port, port 119.
Constructors
Creates a new Net::NNTP object.
address is the hostname or ip address of your NNTP server. port is the port to connect to; it defaults to port 119.
This method does not opens any TCP connection. You can use Net::NNTP.start
instead of new if you want to do everything at once. Otherwise,
follow new with start.
Class methods
Instance methods
Opens a TCP connection and starts the NNTP session.
Parameters
If both of user and secret are given, NNTP authentication will be
attempted using the AUTH command. The method specifies the type of
authentication to attempt; it must be one of Net::NNTP::Commands::Auth::AUTH_METHODS.
See the discussion of NNTP Authentication in the overview notes.
Block Usage
When this methods is called with a block, the newly-started NNTP object
is yielded to the block, and automatically closed after the block call
finishes. Otherwise, it is the caller's responsibility to close the
session when finished via finish.
Example
This is very similar to the class method NNTP.start.
require "nntp-lib"
nntp = Net::NNTP.new("secure.usenetserver.com", 563)
nntp.start(user: "myuser", secret: "pass", :original)
# Perform nntp requests here
nntp.finish
With block that will call finish when complete
require "nntp-lib"
nntp = Net::NNTP.new("secure.usenetserver.com", 563)
nntp.start(user: "myuser", secret: "pass", :original) do |socket|
# Perform nntp requests here
end
The primary use of this method (as opposed to NNTP.start) is probably
to delay socket creation and connection till a later time.
Errors
If session has already been started, an IO::Error will be raised.
This method may raise:
Net::NNTP::Error::AuthenticationErrorNet::NNTP::Error::FatalErrorNet::NNTP::Error::ServerBusyNet::NNTP::Error::SyntaxErrorNet::NNTP::Error::UnknownErrorIO::ErrorIO::TimeoutError
Opens a TCP connection and starts the NNTP session.
Parameters
If both of user and secret are given, NNTP authentication will be
attempted using the AUTH command. The method specifies the type of
authentication to attempt; it must be one of Net::NNTP::Commands::Auth::AUTH_METHODS.
See the discussion of NNTP Authentication in the overview notes.
Block Usage
When this methods is called with a block, the newly-started NNTP object
is yielded to the block, and automatically closed after the block call
finishes. Otherwise, it is the caller's responsibility to close the
session when finished via finish.
Example
This is very similar to the class method NNTP.start.
require "nntp-lib"
nntp = Net::NNTP.new("secure.usenetserver.com", 563)
nntp.start(user: "myuser", secret: "pass", :original)
# Perform nntp requests here
nntp.finish
With block that will call finish when complete
require "nntp-lib"
nntp = Net::NNTP.new("secure.usenetserver.com", 563)
nntp.start(user: "myuser", secret: "pass", :original) do |socket|
# Perform nntp requests here
end
The primary use of this method (as opposed to NNTP.start) is probably
to delay socket creation and connection till a later time.
Errors
If session has already been started, an IO::Error will be raised.
This method may raise:
Net::NNTP::Error::AuthenticationErrorNet::NNTP::Error::FatalErrorNet::NNTP::Error::ServerBusyNet::NNTP::Error::SyntaxErrorNet::NNTP::Error::UnknownErrorIO::ErrorIO::TimeoutError