CURLOPT_CONNECTTIMEOUT 和 CURLOPT_TIMEOUT的区别
There's a very distinctive difference between these two configurations within cURL. I'll try to definethemfor you, and then provide you a very common example which I shareto people who I teach about cURL.
CURLOPT_CONNECTTIMEOUT is designed to tell the script how long to wait to make a successful connection 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 cURL to download a MP3 file. CURLOPT_CONNECTTIMEOUT would be set at about 10 seconds which would mean that if no response is provided within 10 seconds then the script will abort, and CURLOPT_TIMEOUT would be set at about 100 seconds which would mean if the MP3 has not downloaded within 100 seconds then abort the script. It's the best way of explaining it to developers.
What the different CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT