public ServerQueueStatus connect(EndpointManager endpointManager, ServerLocation location,
      ClientSideHandshake handshake, int socketBufferSize, int handshakeTimeout, int readTimeout,
      CommunicationMode communicationMode, GatewaySender sender, SocketCreator sc,
      SocketFactory socketFactory)
      throws IOException {
    theSocket =
        sc.forClient().connect(new HostAndPort(location.getHostName(), location.getPort()),
            handshakeTimeout,
            socketBufferSize, socketFactory::createSocket);
    theSocket.setTcpNoDelay(true);
    theSocket.setSendBufferSize(socketBufferSize);

    // Verify buffer sizes
    verifySocketBufferSize(socketBufferSize, theSocket.getReceiveBufferSize(), "receive");
    verifySocketBufferSize(socketBufferSize, theSocket.getSendBufferSize(), "send");

    theSocket.setSoTimeout(handshakeTimeout);
    out = theSocket.getOutputStream();
    in = theSocket.getInputStream();
    status = handshake.handshakeWithServer(this, location, communicationMode);
    commBuffer = ServerConnection.allocateCommBuffer(socketBufferSize, theSocket);
    if (sender != null) {
      commBufferForAsyncRead = ServerConnection.allocateCommBuffer(socketBufferSize, theSocket);
    }
    theSocket.setSoTimeout(readTimeout);

    Endpoint tempEndpoint = null;

    if (location instanceof ServerLocationExtension) {
      tempEndpoint = getEndpoint(endpointManager, (ServerLocationExtension) location);
    }

    if (tempEndpoint == null || tempEndpoint.isClosed()) {
      tempEndpoint = endpointManager.referenceEndpoint(location, status.getMemberId());
    }

    endpoint = tempEndpoint;
    connectFinished = true;
    endpoint.getStats().incConnections(1);
    return status;
  }
Test hook to simulate a client crashing. If true, we will not notify the server when we close
the connection.
geode-core/src/main/java/org/apache/geode/cache/client/internal/ConnectionImpl.java