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);
}