【问题标题】:PHP Curl - If no response within a certain time, proceed [duplicate]PHP Curl - 如果在一定时间内没有响应,请继续[重复]
【发布时间】:2013-05-21 20:07:57
【问题描述】:

我有一个网络系统,可以检查其他网站并显示结果。但是,其中一些网站的响应速度可能会很慢。

我希望 Curl 稍等片刻,然后说“忘记这个网站!”并进入下一个。

在这么多“空闲”时间之后,如何让 curl 中止一次尝试?

我没有发布任何代码的原因是因为我什至不知道从哪里开始使用此功能! 善良。:D

【问题讨论】:

    标签: php curl time python-idle abort


    【解决方案1】:

    您有两个单独的超时选项:

    CURLOPT_CONNECTTIMEOUT
    Time (in seconds) spent connecting (set to 0 for infinite wait time)
    
    CURLOPT_TIMEOUT
    Time (in seconds) spent while curl is executing (set to 0 for inifinite wait time)
    

    【讨论】:

      【解决方案2】:

      查看手册中的 CURLOPT_TIMEOUT 和 CURLOPT_CONNECTTIMEOUT。另外,在发布之前搜索 Stack Overflow - Setting Curl's Timeout in PHP

      【讨论】:

      • 问题的一半是不知道要搜索的术语。我搜索了“中止”,这样的......“超时”会把我带到那里,但我没有想到这样的术语。 简而言之,我就是这样做的。
      猜你喜欢
      • 2023-04-03
      • 2021-07-25
      • 1970-01-01
      • 2017-08-24
      • 1970-01-01
      • 2021-12-26
      • 2017-10-06
      • 2018-03-24
      • 2021-06-30
      相关资源
      最近更新 更多