What the different CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT
There"s a very distinctive differencebetween
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 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 cURLtodownloada MP3 file. CURLOPT_CONNECTTIMEOUTwouldbe set atabout10 seconds whichwouldmeanthatif noresponse isprovided within 10 seconds then the script will abort,andCURLOPT_TIMEOUTwouldbe set at about100 secondswhich wouldmeanif the MP3has notdownloaded within100 seconds then abort the script.It"s the best way of explaining it to developers.
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 cURLtodownloada MP3 file. CURLOPT_CONNECTTIMEOUTwouldbe set atabout10 seconds whichwouldmeanthatif noresponse isprovided within 10 seconds then the script will abort,andCURLOPT_TIMEOUTwouldbe set at about100 secondswhich wouldmeanif the MP3has notdownloaded within100 seconds then abort the script.It"s the best way of explaining it to developers.
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。