import java.net.*;
import java.io.*;

public class KnockKnockMultiServer {
	
	private static final int PORT = 4444;
	public static void main(String[] arg) {
		
		ServerSocket serverSocket = null;
		try {
			serverSocket = new ServerSocket(PORT);
		} catch (IOException e) {
			System.err.println("could not connect server");
			e.printStackTrace();
		}
		Socket connection = null;
		while(true) {
			try {
				connection = serverSocket.accept();
				new Thread(new KnockKnockTask(connection)).start();
			}catch (IOException ioe) {
				System.err.println(ioe);
				System.exit(1);
			}
		}
	}
}
