2013-11-01 124 views
0

我編寫了一個類似libcur的sendrecv樣本的應用程序(示例網址爲:http://curl.haxx.se/libcurl/c/sendrecv.html)。 所不同的是,我的應用程序在一個循環線程中永遠重複發送/接收。添加設置其它參數:爲什麼curl_easy_send在網絡丟失時不會返回超時

code =curl_easy_setopt(m_curl, CURLOPT_NOSIGNAL, 1L); 
    code =curl_easy_setopt(m_curl, CURLOPT_CONNECTTIMEOUT, 1L); 
    code =curl_easy_setopt(m_curl, CURLOPT_TCP_NODELAY, 1L); 
    //code =curl_easy_setopt(m_curl, CURLOPT_TIMEOUT_MS, 200);//200 milli secs 
    code =curl_easy_setopt(m_curl, CURLOPT_TIMEOUT, 1L); 

但是當網絡丟失,如電纜從網卡接口拉出。 curl_easy_send總是返回CURLE_OK。這似乎是CURLOPT_TIMEOUT沒有效果。是否有任何使用錯誤或其他問題?如果我想知道網絡立即丟失,該怎麼辦。

+0

也許我對libcurl有一些錯誤的理解。也許curl_easy_send只調用BSD套接字的發送方法。 – Johnny

回答

0

CURLOPT_TIMEOUT對curl_easy_send()沒有影響。

+0

我該怎麼辦?做一些檢查應用程序?如心跳機制。 – Johnny

相關問題