docs: private void closeSock() {
          if (sock == null) {
              return;
          }
  
          LOG.debug("Closed socket connection for client "
                  + sock.socket().getRemoteSocketAddress()
                  + (sessionId != 0 ?
                          " which had sessionid 0x" + Long.toHexString(sessionId) :
                          " (no session established for client)"));
          try {
              /*
               * The following sequence of code is stupid! You would think that
               * only sock.close() is needed, but alas, it doesn't work that way.
               * If you just do sock.close() there are cases where the socket
               * doesn't actually close...
               */
              sock.socket().shutdownOutput();
          } catch (IOException e) {
              // This is a relatively common exception that we can't avoid
              if (LOG.isDebugEnabled()) {
                  LOG.debug("ignoring exception during output shutdown", e);
              }
          }
          try {
              sock.socket().shutdownInput();
          } catch (IOException e) {
              // This is a relatively common exception that we can't avoid
              if (LOG.isDebugEnabled()) {
                  LOG.debug("ignoring exception during input shutdown", e);
              }
          }
          try {
              sock.socket().close();
          } catch (IOException e) {
              if (LOG.isDebugEnabled()) {
                  LOG.debug("ignoring exception during socket close", e);
              }
          }
          try {
              sock.close();
              // XXX The next line doesn't seem to be needed, but some posts
              // to forums suggest that it is needed. Keep in mind if errors in
              // this section arise.
              // factory.selector.wakeup();
          } catch (IOException e) {
              if (LOG.isDebugEnabled()) {
                  LOG.debug("ignoring exception during socketchannel close", e);
              }
          }
          sock = null;
      }