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没有效果。是否有任何使用错误或其他问题?如果我想知道网络立即丢失,该怎么办。
也许我对libcurl有一些错误的理解。也许curl_easy_send只调用BSD套接字的发送方法。 – Johnny