FileDocCategorySizeDatePackage
SimpleWebServer.javaAPI DocExample5071Mon Oct 16 19:44:02 BST 2000None

SimpleWebServer

public class SimpleWebServer extends Object

Fields Summary
private ServerSocket
ss
Constructors Summary
public SimpleWebServer(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 SimpleWebServer( args[0] ).run();
      }
      else
      {  new SimpleWebServer( "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 ).run();
      }