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

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

package alice.daemon;

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.nio.channels.ServerSocketChannel;

public class AliceDaemon {
	
	private Config conf;
	private AcceptThread acceptThread;
	
	public AliceDaemon(Config conf) {
		this.conf = conf;
	}
	
	public void listen() {
		try {
			ServerSocketChannel ssChannel = ServerSocketChannel.open();
			ServerSocket ss = ssChannel.socket();
			ss.setReuseAddress(true);
			ss.bind(new InetSocketAddress(InetAddress.getLocalHost(), conf.port));
			acceptThread = new AcceptThread(ss, "ACCEPT" + conf.port);
			acceptThread.start();
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
}