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