Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 35,552 times

Contents

Related Categories

How to NNTP in C# - Using the NNTP class

randy

Using the NNTP class

Using our NNTP class is quite trivial. An example follows.

static void Main(string[] args)
{
    try
    {
        Nntp obj = new Nntp();
        obj.Connect(" news.devx.com");
        ArrayList list = obj.GetNewsgroups();
        foreach (string newsgroup in list)
        {
            System.Console.WriteLine(" Newsgroup :{0}",
                newsgroup);
        }
        list = obj.GetNews(" test");
        foreach (string article in list)
        {
            System.Console.WriteLine("{0}", article);
        }
        obj.Post(" test", "Hello",
            "randy@ kbcafe.com (Randy Charles Morin)", "Goodbye");
        obj.Disconnect();
    }
    catch (NntpException e )
    {
        System.Console.WriteLine(e.ToString());
    }
    catch (System.Exception )
    {
        System.Console.WriteLine(" Unhandled Exception");
    }
}

Instantiate an Nntp object and call Connect passing the NNTP server name. Then we can repeatedly call GetNewsgroups, GetNews and Post to receive and post articles in the forums found on the NNTP server. Finally you call the Disconnect method to release the socket connection to our NNTP server.

The RFC for NNTP is RFC 977 and can be found at the IETF website. You should also review the RFC for the USENET news message format as presented in RFC 850.

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

Comments

  • Re: [4472] How to NNTP in C#

    Posted by RonaldJJames on 08 Apr 2006

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

  • The Only Problem...

    Posted by iancaz on 20 Apr 2005

    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!

  • Excellent tutorial

    Posted by alberto1964 on 01 Oct 2004


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