docs: private void handleSelectedKeys() {
      Set<SelectionKey> selectedKeys = selector.selectedKeys();
      Iterator<SelectionKey> keyIterator = selectedKeys.iterator();
      while (keyIterator.hasNext()) {
        SelectionKey key = keyIterator.next();
        keyIterator.remove();
  
        ISelectHandler callback = (ISelectHandler) key.attachment();
  
        if (!key.isValid()) {
          // This method key.channel() will continue to return the channel even after the
          // key is cancelled.
          callback.handleError(key.channel());
          continue;
        }
  
        // We need to check whether the key is still valid since:
        // 1. The key could be cancelled by last operation
        // 2. The process might not fail-fast or throw exceptions after the key is cancelled
        if (key.isValid() && key.isWritable()) {
          callback.handleWrite(key.channel());
        }
  
        if (key.isValid() && key.isReadable()) {
          callback.handleRead(key.channel());
        }
  
        if (key.isValid() && key.isConnectable()) {
          callback.handleConnect(key.channel());
        }
  
        if (key.isValid() && key.isAcceptable()) {
          callback.handleAccept(key.channel());
        }
  
      }
    }