Today, I studied the Curl download parameters of PHP: Curlopt_connecttimeout and Curlopt_timeout differences:
Curlopt_connecttimeout
Tell the PHP script how long to wait before successfully connecting to the server, this parameter is to deal with the target server overload, offline, or crash and other possible conditions;
curl_setopt ($conn, curlopt_connecttimeout,10); , identify if the server does not respond within 10 seconds, the script will be disconnected;
Curlopt_timeout
Tells you how long the php script waits before the server receives a buffer to complete. This parameter can be useful if the target is a large file, the generated content is too slow, or the link is too slow.
curl_setopt ($conn, curlopt_timeout, 100); If the file to be downloaded is not downloaded within 100 seconds, the script will disconnect.
Curlopt_connecttimeout is used to tell the PHP script how long to wait before successfully connecting to the server (after the connection is successful, it will start buffering output), which is to deal with the possibility of overload, off-line, or crash of the target server.
Curlopt_timeout is used to tell a successful PHP script how long it will take to wait before the server receives a buffer to complete. This parameter can be useful if the target is a large file, the generated content is too slow, or the link is too slow.
Using Curl to download MP3 files is a good example for developers. Curlopt_connecttimeout
Can be set to 10 seconds, identifying if the server does not respond within 10 seconds, the script will disconnect, Curlopt_timeout can be set to 100, and if the MP3 file is not downloaded within 100 seconds, the script will disconnect.