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.

你可能感兴趣的:(What the different CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT)