Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Enterprise
Expertise: Advanced
Sep 13, 2000

Create a NNTP Offline Server

Here's the code to simulate a simple NNTP server that provides offline news reader support to WebReader. Hope you enjoy it.
 import java.util.*;
   import java.io.*;
   import java.net.*;

   class nntpServer
       {
           public nntpServer()
                 {
                  ServerSocket  nntp_socket = null;

                  Socket inbound = null;

                  Thread  nntp_thread;

/*********************************************/
/*  Open a new socket connection on the NNTP port to */
/*  accept commands from WebReader, and listen until */
/*  the connection is broken by the client. The      */
/*  ServerThread() class handles client requests.    */ 
/*********************************************/
                  try
                    {
                   nntp_socket = new ServerSocket(119);
                   while(true)
                      {
                       inbound = nntp_socket.accept();
                       nntp_thread = new ServerThread(inbound);
                       nntp_thread.start();
                         }
                        }
                     catch (IOException e)
                        {
                        System.out.println(
                          "Error connecting to socket: " + e);
                        System.exit(0);
                       }
                     }

                   public static void main(String args[])
                      {
                      new nntpServer();
                      } 
                    }
Jose Antonio
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap