view src/alice/daemon/AcceptThread.java @ 13:30f97d776a3e

implements Alice daemon
author one
date Fri, 13 Jan 2012 19:04:59 +0900
parents c4d6ff56b9bf
children e3f1b21718b0
line wrap: on
line source

package alice.daemon;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class AcceptThread extends Thread {

	private ServerSocket ss;

	public AcceptThread(ServerSocket ss, String name) {
		super(name);
		this.ss = ss;
	}
	
	@Override
	public void run() {
		while (true) {
			try {
				Socket socket = ss.accept();
				Connection connection = new Connection(socket);
				new IncomingTcpConnection(connection).start();
				new OutboundTcpConnection(connection).start();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}