diff src/alice/daemon/AliceDaemon.java @ 12:c4d6ff56b9bf

unite Command and Reply and add Network outline
author one
date Fri, 13 Jan 2012 07:04:38 +0900
parents
children e3f1b21718b0
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/daemon/AliceDaemon.java	Fri Jan 13 07:04:38 2012 +0900
@@ -0,0 +1,32 @@
+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(String[] args) {
+		this.conf = new Config(args);
+	}
+	
+	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();
+		}
+		
+	}
+}