Mercurial > hg > FederatedLinda
view src/fdl/AcceptHandler.java @ 22:56e015e8f5dc
Testing TestLindaServer
author | kono |
---|---|
date | Tue, 19 Aug 2008 16:02:48 +0900 |
parents | 0243987383b7 |
children | fe338d497c72 |
line wrap: on
line source
package fdl; import java.io.IOException; import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectionKey; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; public class AcceptHandler implements TupleHandler { public TupleSpace tupleSpace; public AcceptHandler(TupleSpace tupleSpace) { // 読みこんだデータを格納するためのリストの初期化 this.tupleSpace = tupleSpace; } public void handle(SelectionKey key) throws ClosedChannelException, IOException { ServerSocketChannel serverChannel = (ServerSocketChannel)key.channel(); // アクセプト処理 SocketChannel channel = serverChannel.accept(); channel.configureBlocking(false); System.out.println("Server: accepted "+channel.socket()); tupleSpace.newUser(); // 入出力用のハンドラを生成し,アタッチする // 監視する操作は読み込みのみ channel.register(key.selector(), SelectionKey.OP_READ, new IOHandler(tupleSpace,channel)); } }