comparison src/fdl/FDLindaServ.java @ 20:a0fd653d1121

Debug Client and Meta Engine for logging.
author kono
date Tue, 19 Aug 2008 06:26:20 +0900
parents 0243987383b7
children fac6e0073b1a
comparison
equal deleted inserted replaced
19:0243987383b7 20:a0fd653d1121
16 static final int DEF_PORT = 10000; 16 static final int DEF_PORT = 10000;
17 //public static final int TIMEOUT = 5*1000; 17 //public static final int TIMEOUT = 5*1000;
18 public int port = DEF_PORT; 18 public int port = DEF_PORT;
19 private AbstractSelector selector; 19 private AbstractSelector selector;
20 private ServerSocketChannel ssChannel; 20 private ServerSocketChannel ssChannel;
21 public TupleSpace tupleSpace;
21 22
22 public static void main(final String[] args) { 23 public static void main(final String[] args) {
23 final String usages = "usage: FDLindaServ [-p port]"; 24 final String usages = "usage: FDLindaServ [-p port]";
24 //バイトオーダー確認 25 //バイトオーダー確認
25 //System.out.println(ByteOrder.nativeOrder().toString()); 26 //System.out.println(ByteOrder.nativeOrder().toString());
44 System.err.println("Server Communiation Problem."); 45 System.err.println("Server Communiation Problem.");
45 } 46 }
46 } 47 }
47 48
48 private void mainLoop() { 49 private void mainLoop() {
50 MetaLinda ml = new MetaLinda(tupleSpace, this);
51 MetaEngine me = new MetaEngine(ml);
49 while(true) { 52 while(true) {
50 checkTuple(); 53 me.mainLoop();
51 } 54 }
52 } 55 }
53 56
54 public FDLindaServ(int port) throws IOException { 57 public FDLindaServ(int port) throws IOException {
55 this.port = port; 58 this.port = port;
61 ssChannel.socket().bind(address); 64 ssChannel.socket().bind(address);
62 ssChannel.configureBlocking(false); 65 ssChannel.configureBlocking(false);
63 //ssChannel.socket().setReuseAddress(true); 66 //ssChannel.socket().setReuseAddress(true);
64 System.out.println("Server: litening at "+ssChannel); 67 System.out.println("Server: litening at "+ssChannel);
65 //セレクタにチャンネルを登録 68 //セレクタにチャンネルを登録
66 TupleSpace tupleSpace = new TupleSpace(); 69 tupleSpace = new TupleSpace();
67 ssChannel.register(selector, SelectionKey.OP_ACCEPT, new AcceptHandler(tupleSpace)); 70 ssChannel.register(selector, SelectionKey.OP_ACCEPT, new AcceptHandler(tupleSpace));
68 71
69 72
70 } 73 }
71 74