FileDocCategorySizeDatePackage
KKMultiServerThread.javaAPI DocExample907Tue Dec 12 18:58:32 GMT 2000None

KKMultiServerThread

public class KKMultiServerThread extends Thread

Fields Summary
private Socket
socket
Constructors Summary
public KKMultiServerThread(Socket socket)


       
	super("KKMultiServerThread");
	this.socket = socket;
    
Methods Summary
public voidrun()


	try {
	    PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
	    BufferedReader in = new BufferedReader(
				    new InputStreamReader(
				    socket.getInputStream()));

	    String inputLine, outputLine;
	    KnockKnockProtocol kkp = new KnockKnockProtocol();
	    outputLine = kkp.processInput(null);
	    out.println(outputLine);

	    while ((inputLine = in.readLine()) != null) {
		outputLine = kkp.processInput(inputLine);
		out.println(outputLine);
		if (outputLine.equals("Bye"))
		    break;
	    }
	    out.close();
	    in.close();
	    socket.close();

	} catch (IOException e) {
	    e.printStackTrace();
	}