/**
   * Starts the thread that does the timeout stuff & sets the content authority. The content
   * authority is attempted to be set here instead of outside this thread because looking up the DNS
   * name can block.
   */
  protected void startProcessingThread() {
    Thread timeouter =
        ThreadExecutor.newManagedThread(
            new Runnable() {
              public void run() {
                // if no existing authority, try and make one.
                if (authority == null) setDefaultContentAuthority();

                while (true) {
                  if (shutdown) return;
                  try {
                    try {
                      Thread.sleep(1000);
                    } catch (InterruptedException ix) {
                    }
                    if (!shutdown) timeout(System.currentTimeMillis());
                  } catch (Throwable t) {
                    ErrorService.error(t);
                  }
                }
              }
            },
            "ContentProcessor");
    timeouter.setDaemon(true);
    timeouter.start();
  }
    public void handleAccept(final Socket socket) throws IOException {
      ThreadExecutor.startThread(
          new Runnable() {
            public void run() {
              try {
                if (badHandshake) {
                  socket.close();
                  return;
                }
                socket.setSoTimeout(3000);
                InputStream in = socket.getInputStream();
                String word = IOUtils.readWord(in, 9);
                if (!word.equals("GNUTELLA")) throw new IOException("Bad word: " + word);

                if (noGOK) {
                  socket
                      .getOutputStream()
                      .write(StringUtils.toAsciiBytes("GNUTELLA/0.6 401 Failed\r\n\r\n"));
                  socket.getOutputStream().flush();
                  return;
                }

                Injector injector = LimeTestUtils.createInjector();
                BlockingConnectionFactory connectionFactory =
                    injector.getInstance(BlockingConnectionFactory.class);
                HandshakeResponderFactory handshakeResponderFactory =
                    injector.getInstance(HandshakeResponderFactory.class);
                final BlockingConnection con = connectionFactory.createConnection(socket);
                con.initialize(
                    null,
                    handshakeResponderFactory.createUltrapeerHandshakeResponder("127.0.0.1"),
                    1000);
              } catch (IOException e) {
                throw new RuntimeException(e);
              }
            }
          },
          "conninit");
    }