view src/alice/daemon/AcceptThread.java @ 14:e3f1b21718b0

implements RemoteDataSegment
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Sun, 15 Jan 2012 00:56:25 +0900
parents 30f97d776a3e
children 45e98e74db96
line wrap: on
line source

package alice.daemon;

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

import alice.datasegment.DataSegment;

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, DataSegment.get("local")).start();
				new OutboundTcpConnection(connection).start();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}