EchoServerThreaded2public class EchoServerThreaded2 extends Object Threaded Echo Server, pre-allocation scheme. |
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 void | main(java.lang.String[] av)Main method, to start the servers.
new EchoServerThreaded2(ECHOPORT, NUM_THREADS);
|
|