FileDocCategorySizeDatePackage
EchoServerThreaded2.javaAPI DocExample2069Thu Jan 03 08:56:46 GMT 2002None

EchoServerThreaded2

public class EchoServerThreaded2 extends Object
Threaded Echo Server, pre-allocation scheme.
author
Ian F. Darwin.

Fields Summary
public static final int
ECHOPORT
public static final int
NUM_THREADS
Constructors Summary
public EchoServerThreaded2(int port, int numThreads)
Constructor

		ServerSocket servSock;
		Socket clientSocket;

		try {
			servSock = new ServerSocket(ECHOPORT);
		
		} catch(IOException e) {
			/* Crash the server if IO fails. Something bad has happened */
			System.err.println("Could not create ServerSocket " + e);
			System.exit(1);
			return;	/*NOTREACHED*/
		}

		// Create a series of threads and start them.
		for (int i=0; i<numThreads; i++) {
			new Thread(new Handler(servSock, i)).start();
		}
	
Methods Summary
public static voidmain(java.lang.String[] av)
Main method, to start the servers.


	       
	    
	
		new EchoServerThreaded2(ECHOPORT, NUM_THREADS);