posted 20 years ago
hi..guys,i encountered some problems with NIO,the situation is :
I implemented a server with NIO,and implemented a client with the traditional blocking socket.
Firstly, i registered the client socket channel with the OP_READ and OP_WRITE operations when the serve accept the connection,the code is :
//////////////////////////////////////////
if (key.isAcceptable()){
ServerSocketChannel server =(ServerSocketChannel) key.channel();
SocketChannel clientChannel = server.accept();
clientChannel.configureBlocking(false);
clientChannel.register(this.selector,SelectionKey.OP_READ|SelectionKey.OP_WRITE);
////////////////////////////////////////
when the client is running, it will sending a byte array to the serve per second,but i found that the server just knew the accpet and write event,in other words,no READ key will be selected, i feel confused about this...