为什么curl_easy_send在网络丢失时不返回超时

why curl_easy_send does't return timeout when network is lost

本文关键字:返回 超时 网络 curl easy send 为什么      更新时间:2023-10-16

我写了一个应用程序,比如libcur的sendrecv示例(示例网址是:http://curl.haxx.se/libcurl/c/sendrecv.html)。不同的是,我的应用程序在循环线程中永远重复发送/接收。添加设置其他参数:

    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没有效果。是否有任何使用错误或其他问题?如果我想知道网络立即丢失,该怎么办。

>CURLOPT_TIMEOUT对curl_easy_send()没有影响。