FileDocCategorySizeDatePackage
KKMultiServerThread.javaAPI DocExample1214Tue 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 {
            DataInputStream in = new DataInputStream(
                                  new BufferedInputStream(socket.getInputStream()));
            PrintStream out = new PrintStream(
                              new BufferedOutputStream(socket.getOutputStream(), 1024), false);

            String inputLine, outputLine;
	    KnockKnockProtocol kkp = new KnockKnockProtocol();

            outputLine = kkp.processInput(null);
            out.println(outputLine);
            out.flush();

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