devxlogo

Create a NNTP Offline Server

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();                      }                     }

devx-admin

Share the Post: