code: protected final Object blockingWrite(SelectableChannel channel,
  			WriteMessage message, IoBuffer writeBuffer) throws IOException,
  			ClosedChannelException {
  		SelectionKey tmpKey = null;
  		Selector writeSelector = null;
  		int attempts = 0;
  		int bytesProduced = 0;
  		try {
  			while (writeBuffer.hasRemaining()) {
  				long len = doRealWrite(channel, writeBuffer);
  				if (len > 0) {
  					attempts = 0;
  					bytesProduced += len;
  					statistics.statisticsWrite(len);
  				} else {
  					attempts++;
  					if (writeSelector == null) {
  						writeSelector = SelectorFactory.getSelector();
  						if (writeSelector == null) {
  							// Continue using the main one.
  							continue;
  						}
  						tmpKey = channel.register(writeSelector,
  								SelectionKey.OP_WRITE);
  					}
  					if (writeSelector.select(1000) == 0) {
  						if (attempts > 2) {
  							throw new IOException("Client disconnected");
  						}
  					}
  				}
  			}
  			if (!writeBuffer.hasRemaining() && message.getWriteFuture() != null) {
  				message.getWriteFuture().setResult(Boolean.TRUE);
  			}
  		} finally {
  			if (tmpKey != null) {
  				tmpKey.cancel();
  				tmpKey = null;
  			}
  			if (writeSelector != null) {
  				// Cancel the key.
  				writeSelector.selectNow();
  				SelectorFactory.returnSelector(writeSelector);
  			}
  		}
  		scheduleWritenBytes.addAndGet(0 - bytesProduced);
  		return message.getMessage();
  	}
docs: Blocking write using temp selector
  
  @param channel
  @param message
  @param writeBuffer
  @return
  @throws IOException
  @throws ClosedChannelException