@Override
  public Socket connect(HostAndPort addr, int timeout,
      ConnectionWatcher optionalWatcher, boolean allowClientSocketFactory,
      int socketBufferSize, boolean useSSL, TcpSocketFactory socketFactory)
      throws IOException {
    if (useSSL) {
      throw new IllegalArgumentException();
    }
    Socket socket = null;
    if (allowClientSocketFactory) {
      socket = createCustomClientSocket(addr);
    }
    if (socket == null) {
      socket = socketFactory.createSocket();

      // Optionally enable SO_KEEPALIVE in the OS network protocol.
      socket.setKeepAlive(ENABLE_TCP_KEEP_ALIVE);

      if (socketBufferSize != -1) {
        socket.setReceiveBufferSize(socketBufferSize);
      }
      if (optionalWatcher != null) {
        optionalWatcher.beforeConnect(socket);
      }
      InetSocketAddress inetSocketAddress = addr.getSocketInetAddress();
      try {
        socket.connect(inetSocketAddress, Math.max(timeout, 0));
      } catch (ConnectException connectException) {
        logger.info("Failed to connect to " + inetSocketAddress);
        throw connectException;
      } finally {
        if (optionalWatcher != null) {
          optionalWatcher.afterConnect(socket);
        }
      }
    }
    return socket;
  }
AdvancedSocketCreatorImpl is constructed and held by a TcpSocketCreator. It is
accessed through the method {@link TcpSocketCreator#forAdvancedUse()}.
geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/AdvancedSocketCreatorImpl.java