void start() throws IOException {
    socket.bind(null);
    Thread t = new Thread(() -> {
      while (true) {
        try (@SuppressWarnings("unused") Socket clientSocket = socket.accept()) {
        } catch (IOException exception) {
          throw new UncheckedIOException(exception);
        }
      }
    }, "ListeningServer-" + socket.getLocalPort() + "-" + ID.getAndIncrement());
    t.start();
  }
A TCP server that accepts a client connection and closes it immediately.
testutils/src/java/org/apache/hive/testutils/junit/extensions/DoNothingTCPServer.java