我正在使用libcurl
創建到服務器的http連接。在初始化期間,我指定了5秒的空閒超時值,並且還指定爲進度回調函數。我期待cURL在5秒鐘不活動後中止連接並停止調用進度回調,但是我發現大約15秒鐘後curl超時。爲什麼curl需要更多的時間來超時我比我指定的?將超時設置爲較大的值不會有幫助。如果我指定100秒,則在105秒不活動後超時。cURL:空閒超時間隔超過指定值
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);
編輯:超時代碼
//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);
編輯問題添加超時代碼。 – 341008 2010-11-15 05:02:22