Library tutorials & articles

How to NNTP in C#

Introduction

This is the third in a series of articles on Internet programming with Microsoft's new C# programming language. In the first two articles, I wrote two simple TCP/ IP classes for SMTP and POP3 clients. In this article, I'm going to write a simple NNTP class.

NNTP is an older fading protocol in the Internet protocol family. The protocol is used to retrieve news from news server, a.k.a. NetNews servers. The protocol works by posting messages into various forums, a.k.a. newsgroups. Then other end-users can read the recent posts in the forums. There also exist protocols for distributing NetNews contents amongst various NetNews servers, allowing thousands of servers to share news and forums. The most popular news server is of course Microsoft's [nntp://news.microsoft.com]. More often than not, you can launch your NetNews client by typing the nntp URL in your browser's address bar.

public class NntpException : System.ApplicationException
{
    public NntpException(string str)
        :base(str)
    {
    }
};

I'm still unsure how best to implement exception classes in .NET and as such I've remained faithful to my C++ roots. I'm investigating otherwise and might consider writing a brief article on just this subject. We'll see. Next step is the class declaration. I'm deriving the Nntp class from the TcpClient class in the System.Net.Sockets namespace of the .NET framework.

public class Nntp : System.Net.Sockets.TcpClient

We'll inherit a lot of basic functionality from the TcpClient class.

Comments

  1. 08 Apr 2006 at 22:54

    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

     

  2. 20 Apr 2005 at 21:35

    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!

  3. 01 Oct 2004 at 08:59


    This saved me days of work ! Thanks, really excellent.

  4. 01 Jan 1999 at 00:00

    This thread is for discussions of How to NNTP in C#.

Leave a comment

Sign in or Join us (it's free).

Randy Charles Morin Randy's article are Copyright 1998-2003 Randy Charles Morin

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...

Want to stay in touch with what's going on? Follow us on twitter!