예제 #1
0
 private void send(SocketChannel sc, ClientInfo ci) throws IOException {
   int len = ci.outBuf.remaining();
   int nBytes = sc.write(ci.outBuf);
   if (nBytes != len) {
     // Client not ready to receive data
     ci.outputPending = true;
     ci.channel.register(selector, SelectionKey.OP_READ | SelectionKey.OP_WRITE);
   } else {
     ci.outBuf.clear();
     if (ci.outputPending) {
       ci.outputPending = false;
       ci.channel.register(selector, SelectionKey.OP_READ);
     }
   }
 }