什么选项会导致curl重新连接无限次? [英] What option causes curl to reconnect infinite times?
问题描述
我正在使用curl将文件上传到远程服务器。如果我添加到远程服务器 iptables
规则拒绝来自客户端的访问,我希望客户端继续尝试重新连接到远程服务器。启用详细模式后,我发现第三次上传超时后,第四次curl不会重新连接到远程服务器。为什么是这样以及如何改变它?有没有在 curl_easy_setopt
?
I'm using curl to upload files to a remote server. If I added to the remote server iptables
rule to deny access from client, I want the client to keep trying to reconnect to the remote server. After enabling verbose mode I see that after the 3rd time the upload timed out, curl will not retry for the 4th time to connect to the remote server. Why is that and how to change it? Is there an option for that in curl_easy_setopt
?
推荐答案
中的选项, curl
将在每次请求的操作超时时尝试重新连接。添加类似 curl_easy_setopt(m_curl,CURLOPT_TIMEOUT,5L)
来添加超时选项。我报告的问题实际上是我的代码中的一个错误。
This happens automatically, curl
will try to reconnect every time the requested operation will timeout. Add something like curl_easy_setopt(m_curl, CURLOPT_TIMEOUT, 5L)
to add timeout option. The problem I have reported was actually a bug in my code.
这篇关于什么选项会导致curl重新连接无限次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!