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

AddThis

Related podcasts

  • Looking into the C# Crystal Ball with Charlie Calvert and Bill Wagner

    One of the most exciting announcements from PDC was the news about C# 4.0 and Visual Studio 2010. With all the excitement and discussion throughout the event about these new developer tools, we reached out to two experts in the fields. Charlie Calvert and Bill Wagner sat down with Keith and Woody...

Events coming up

  • Dec 6

    Developing AJAX Web Applications with Castle Monorail

    London, United Kingdom

    Monorail is the model-view-controller engine of the Castle Project, bringing many of the best ideas of Ruby on Rails to the .NET world. In this talk, David De Florinier and Gojko Adzic show how Monorail makes it easy to develop .NET based AJAX applications, and how to use the Castle Project to build Web 2.0 applications effectively. Come to this session if you are a .NET web developer. Everyone is welcome!