牛骨文教育服务平台(让学习变的简单)
博文笔记

What the different CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT

创建时间:2013-03-28 投稿人: 浏览次数:2422
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.
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。