public Socket connectSocket(
        final Socket socket,
        final Path socketPath,
        final TimeValue connectTimeout
    ) throws IOException {
        Args.notNull(socketPath, "Unix domain socket path");

        final Socket sock = socket != null ? socket : createSocket();
        final SocketAddress address = createSocketAddress(socketPath);
        final int connTimeoutMs = TimeValue.isPositive(connectTimeout) ? connectTimeout.toMillisecondsIntBound() : 0;

        try {
            sock.connect(address, connTimeoutMs);
            return sock;
        } catch (final IOException ex) {
            try {
                sock.close();
            } catch (final IOException ignore) {
            }
            throw ex;
        }
    }
Gets the singleton instance of {@link UnixDomainSocketFactory}.

@return the singleton instance
httpclient5/src/main/java/org/apache/hc/client5/http/socket/UnixDomainSocketFactory.java