@Override
    public void disconnect() {
    synchronized (this) {
      try {
        if (connected || socket != null) {
          if (readChannel != null) {
            readChannel.close();
            readChannel = null;
          }
          if (writeChannel != null) {
            writeChannel.close();
            writeChannel = null;
          }
          socket.close();
          socket = null;
          connected = false;
        }
      } catch (Exception e) {
        logger.error("error while disconnecting {}", e);
      }
    }
  }
Disconnect readChannel, writeChannel and close underlying Socket
ambry-network/src/main/java/com/github/ambry/network/BlockingChannel.java