code: private synchronized void start(InetSocketAddress inetSocketAddress) throws IOException {
      if (started) throw new IllegalStateException("start() already called");
      started = true;
  
      executor = Executors.newCachedThreadPool(Util.threadFactory("MockWebServer", false));
      this.inetSocketAddress = inetSocketAddress;
  
      if (serverSocketFactory == null) {
        serverSocketFactory = ServerSocketFactory.getDefault();
      }
      serverSocket = serverSocketFactory.createServerSocket();
  
      // Reuse if the user specified a port
      serverSocket.setReuseAddress(inetSocketAddress.getPort() != 0);
      serverSocket.bind(inetSocketAddress, 50);
  
      port = serverSocket.getLocalPort();
      executor.execute(new NamedRunnable("MockWebServer %s", port) {
        @Override protected void execute() {
          try {
            logger.info(MockWebServer.this + " starting to accept connections");
            acceptConnections();
          } catch (Throwable e) {
            logger.log(Level.WARNING, MockWebServer.this + " failed unexpectedly", e);
          }
  
          // Release all sockets and all threads, even if any close fails.
          closeQuietly(serverSocket);
          for (Iterator<Socket> s = openClientSockets.iterator(); s.hasNext(); ) {
            closeQuietly(s.next());
            s.remove();
          }
          for (Iterator<Http2Connection> s = openConnections.iterator(); s.hasNext(); ) {
            closeQuietly(s.next());
            s.remove();
          }
          dispatcher.shutdown();
          executor.shutdown();
        }
  
        private void acceptConnections() throws Exception {
          while (true) {
            Socket socket;
            try {
              socket = serverSocket.accept();
            } catch (SocketException e) {
              logger.info(MockWebServer.this + " done accepting connections: " + e.getMessage());
              return;
            }
            SocketPolicy socketPolicy = dispatcher.peek().getSocketPolicy();
            if (socketPolicy == DISCONNECT_AT_START) {
              dispatchBookkeepingRequest(0, socket);
              socket.close();
            } else {
              openClientSockets.add(socket);
              serveConnection(socket);
            }
          }
        }
      });
    }
docs: Starts the server and binds to the given socket address.
  
  @param inetSocketAddress the socket address to bind the server on