PHP Curl get Web content (IPV6 time Out) Workaround _php Tutorial

Source: Internet
Author: User
Reason:
If the Ipv6,curl is turned on by default, the IPV6 will be resolved first, and if the corresponding domain name is not IPv6, it will wait for IPV6 DNS resolution to fail to find IPv4 in accordance with the previous normal process. In the program I have a strict timeout limit for curl to get content, so it will cause the problem of unable to get the content.

WORKAROUND: Set default access to IPv4.
The Curl settings for PHP are as follows:

 =, Curlopt_url, 
         
          , Curlopt_ Returntransfer, 
            
              ( (' curlopt_ipresolve ') &&  (' curl_ipresolve_v4 ') 
                  
                   , Curlopt_ipresolve,curl_setopt (, Curlopt_connecttimeout, 
                        
                         curl_setopt ( , Curlopt_timeout,*3
                             
                               = curl_exec ( span $ch Span>
                               
                                );  
                                
                                 
                          
                  
            
          


Note: curl_setopt ($ch, Curlopt_ipresolve, CURL_IPRESOLVE_V4) The above settings only take effect when the version of PHP version 5.3 and later, Curl version 7.10.8 and above.

http://www.bkjia.com/PHPjc/440400.html www.bkjia.com true http://www.bkjia.com/PHPjc/440400.html techarticle Cause: If Ipv6,curl is turned on, the default priority is to resolve IPV6, if the corresponding domain name does not IPv6, will wait for IPV6 DNS resolution to fail timeout after the normal process to go before ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.