dcsimg
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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


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

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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
Thanks for your registration, follow us on our social networks to keep up-to-date