FileDocCategorySizeDatePackage
ThreadedWebServer.javaAPI DocExample5024Mon Oct 16 19:44:00 BST 2000None

ThreadedWebServer

public class ThreadedWebServer extends Object

Fields Summary
private ServerSocket
ss
Constructors Summary
public ThreadedWebServer(String portNum)

       
     int port = new Integer( portNum ).intValue();
      try
      {  ss = new ServerSocket( port );
      }
      catch( IOException ioe )
      {  System.out.println( "Can't create server socket on port : " + port );
         System.exit( -1 );
      }
   
Methods Summary
public static voidmain(java.lang.String[] args)

  if( args.length == 1 )
      {  new ThreadedWebServer( args[0] ).run();
      }
      else
      {  new ThreadedWebServer( "44444" ).run();
      }
   
public voidrun()

  Socket sock = null;
      int handlerCount = 0;
      while( true )
      {  try
         {  sock = ss.accept();
         }
         catch( IOException ioe )
         {  System.out.println( "Accept failed" );
            System.exit( -1 );
         }
         handlerCount++;
         new ConnectionHandler( sock, handlerCount ).start();
      }