title: 10 second timeout on failing AAAA lookup before IPv4 fallback in file_get_contents in PHP
body: <p>PHP—or its subsystems—delays requests with 10 seconds attempting to get a AAAA lookup before falling back to IPv4 and succeeding. I have 15+ requests, so this problem results in 150 seconds+ spent just waiting for IPv6 lookups to fail. Neither the client nor remote hosts have IPv6 setup other than link-local.</p>
  
  <pre><code>file_get_contents( $ipv4_address); # works in less than a second
  file_get_contents( $fqdn_address); # takes ten–eleven seconds
  </code></pre>
  
  <p>The only viable work-around I see is to use <code>gethostbyname( $fqdn_address );</code> to replace the hostname before sending it to <code>file_get_contents()</code>. I am hoping for a more elegant solution.</p>
  
  <p>PS: This is on a shared host, so I have minimal control over the server configuration and setup.</p>