What the different CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT

There's a very  distinctive  differencebetween these two configurations within cURL. I'll try to definethe mfor you, and then provide you a very common example which I shareto people who I teach about cURL.

CURLOPT_CONNECTTIMEOUT  isdesigned to tell the script how long to wait to make a successfulconnection to the server before starting to buffer the output. Adestination's server which may be overloaded, offline or crashedwould probably make this setting  becomeuseful.

CURLOPT_TIMEOUT  isdesigned to tell the script how long to wait to receive acompletely buffered output from the server. A destination's hugefile, slow connection speeds or slow rendering would probably makethis setting become useful.

A good example of where these will both apply to, is when you'retelling cUR Lto downloada MP3 file. C URLOPT_CONNECTTIMEOUTwo uldbe  s et  atab out10 seconds w hichwo uldmea nth atif  nores ponse  isprovided within 10 seconds then the script will abort,a ndCURLOPT_TI M EOUTw ouldbe set at  abou t100 s econdswhich w ouldmea nif the M P3has no tdownlo aded  within100 seconds then abort the s cript.It's the best way of explaining it to developers.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值