I use libcurl to create an http connection to the server. During initialization, I set a timeout value in standby mode of 5 seconds and also indicated a callback execution function. I expected cURL to terminate the connection after 5 seconds of inactivity and stop calling the progress callback, but I found that the curl expires after about 15 seconds. Why does curl take longer than me, as I pointed out? Setting a timeout to a larger value does not help. If I specify 100 seconds, it will expire after 105 seconds of inactivity.
code = s_curl_easy_setopt(m_curl_handle, CURLOPT_NOPROGRESS, 0); assert(code == CURLE_OK); code = s_curl_easy_setopt(m_curl_handle, CURLOPT_PROGRESSFUNCTION, progress_callback); assert(code == CURLE_OK);
EDIT: timeout code
//this will set the timeout for quitting in case the network goes down code = s_curl_easy_setopt(m_curl_handle, CURLOPT_LOW_SPEED_LIMIT, 1); code = s_curl_easy_setopt(m_curl_handle, CURLOPT_LOW_SPEED_TIME, m_idle_timeout);
source share