code: @SuppressWarnings("resource")
    public void run() {
      Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
      ServerSocketChannel errsock = null;
      boolean saw_error = false;
  
      while( true ) {
        try {
          // Cleanup from any prior socket failures.  Rare unless we're really sick.
          if( errsock != null ) { // One time attempt a socket close
            final ServerSocketChannel tmp2 = errsock; errsock = null;
            tmp2.close();       // Could throw, but errsock cleared for next pass
          }
          if( saw_error ) Thread.sleep(100); // prevent deny-of-service endless socket-creates
          saw_error = false;
  
          // ---
          // More common-case setup of a ServerSocket
          if( SOCK == null ) {
            SOCK = ServerSocketChannel.open();
            SOCK.socket().setReceiveBufferSize(AutoBuffer.BBSIZE);
            SOCK.socket().bind(H2O.SELF._key);
          }
  
          // Block for TCP connection and setup to read from it.
          SocketChannel sock = SOCK.accept();
  
          // Pass off the TCP connection to a separate reader thread
          new TCPReaderThread(sock,new AutoBuffer(sock)).start();
  
        } catch( java.nio.channels.AsynchronousCloseException ex ) {
          break;                  // Socket closed for shutdown
        } catch( Exception e ) {
          // On any error from anybody, close all sockets & re-open
          Log.err("Retrying after IO error on TCP port "+H2O.H2O_PORT +": ",e);
          saw_error = true;
          errsock = SOCK ;  SOCK = null; // Signal error recovery on the next loop
        }
      }
    }
docs: Started by main() on a single thread, this code manages reading TCP requests