FileDocCategorySizeDatePackage
EchoServerThreaded.javaAPI DocExample1523Sun Feb 15 20:44:44 GMT 2004None

EchoServerThreaded

public class EchoServerThreaded extends Object
Threaded Echo Server, sequential allocation scheme.
author
Ian F. Darwin.

Fields Summary
public static final int
ECHOPORT
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] av)


	    
	
		new EchoServerThreaded().runServer();
	
public voidrunServer()

		ServerSocket sock;
		Socket clientSocket;

		try {
			sock = new ServerSocket(ECHOPORT);
		
			System.out.println("EchoServerThreaded ready for connections.");

			/* Wait for a connection */
			while(true){
				clientSocket = sock.accept();
				/* Create a thread to do the communication, and start it */
				new Handler(clientSocket).start();
			}
		} catch(IOException e) {
			/* Crash the server if IO fails. Something bad has happened */
			System.err.println("Could not accept " + e);
			System.exit(1);
		}