Library tutorials & articles
How to NNTP in C#
- Introduction
- Connecting & Disconnecting
- Getting the Newsgroups
- Posting Messages
- Using the NNTP class
Connecting & Disconnecting
The first method of our Nntp client class is the Connect method. This method takes a server name that represents the remote NNTP server that will service our requests.
public void Connect(string server)
{
string response;
Connect(server, 119);
response = Response();
if (response.Substring(0, 3) != "200")
{
throw new NntpException(response);
}
}
We call the Connect method of our base TcpClient class with the server name and port 119. Port 119 is the well-known port for NNTP servers. The server should respond with a status-code indicating that connection was successful. When you are finished calling methods to the Nntp client object, then you should call the Disconnect method to terminate the connection.
public void Disconnect()
{
string message;
string response;
message = "QUIT\r\n";
Write(message);
response = Response();
if (response.Substring(0, 3) != "205")
{
throw new NntpException(response);
}
}
The method will send a QUIT message to the server and the server should respond with a 205 status-code indicating that the it is disconnecting the socket.
When you first instantiate the Nntp object you should call the Connect method and when you are finished you should call the Disconnect method. In between, you can call three method, GetNewsgroups, GetNews and Post, to receive and send news to the NNTP server.
Related articles
Related discussion
-
Help me how to dynamic create row column of TableLayoutpanel at run time ??????
by anatha1 (0 replies)
-
Very Urgent regarding deleting the images from a folder
by rameshbandi (2 replies)
-
How to Export Datagridview contents to Excel
by BarbaMariolino (8 replies)
-
Help accessing sound card
by daz4904 (0 replies)
-
How to Write a GPS Application
by stoyac (19 replies)
Related podcasts
-
Object-Oriented Programming in Ruby
In this episode, I talk with Scott Bellware about object-oriented programming in Ruby, and Ruby's object model. This is taken from a private conversation, and the audio quality suffers at times. Much thanks to Scott for allowing this to be released.This episode of the Alt.NET Podcast is bro...
Great article - thanks.
However I'd like to post HTML to an NNTP server. I'm assuming that I need to specify this in the Header info somehow but can't find any documentation on NNTP message headers.
Could you shed some light here.
Thanks again
The only problem I found with this article, was the missing "Supporting Functions" you included in your other programs. Other than that, this is an awesome article! Keep up the good work!
This saved me days of work ! Thanks, really excellent.
This thread is for discussions of How to NNTP in C#.