Circumventing issue with connecting to IPv6 host via cURL
===

I have an application I distribute for a PHP-based CMS which connects to Google services via cURL. Lately (since Google moved to IPv6 in June), I've had some reports of extremely slow connection times (150 seconds in one case), or lack of connectivity altogether (Example curl error: Failed to connect to 2001:4860:b007::5F: Network is unreachable).

I've found, via SO and other resources, that forcing curl to use IPv4 fixes these issues:

    if(defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4'))
	{
		curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
	}	

My guess is that the servers these requests are being made from are misconfigured (perhaps saying they support IPv6 when they really don't?). But I'm fairly ignorant of the intricacies of IPv6 responses to DNS lookups.

By forcing IPv4, and I setting myself up for errors on servers which *are* properly configured?

Is there a robust method I can use to check for compatibility, and set my cURL options accordingly?
 