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

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist