code: private void close(final SocketChannel channel, final SelectionKey key) {
      try {
        channel.close();
      } catch (Exception e) {
        // already closed; ignore
      }
      try {
        key.cancel();
      } catch (Exception e) {
        // already cancelled/closed; ignore
      }
    }
docs: =========================================