在DNS缓存中找不到Libcurl主机名 [英] Libcurl Hostname was NOT found in DNS cache

查看:191
本文介绍了在DNS缓存中找不到Libcurl主机名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用curl_multi 2进行并行连接:

I'm trying 2 parallel connection with curl_multi :

CURL *http_handle;
CURL *http_handle2;
CURLM *multi_handle;

int still_running; /* keep number of running handles */

http_handle = curl_easy_init();
http_handle2 = curl_easy_init();

/* set options */
curl_easy_setopt(http_handle, CURLOPT_URL, "http://216.58.208.46");

/* set options */
curl_easy_setopt(http_handle2, CURLOPT_URL, "http://213.180.204.62");

curl_easy_setopt(http_handle, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(http_handle2, CURLOPT_VERBOSE, 1L);

/* init a multi stack */
multi_handle = curl_multi_init();

/* add the individual transfers */
curl_multi_add_handle(multi_handle, http_handle);
curl_multi_add_handle(multi_handle, http_handle2);

/* we start some action by calling perform right away */
curl_multi_perform(multi_handle, &still_running);

while(still_running);

curl_multi_cleanup(multi_handle);

curl_easy_cleanup(http_handle);
curl_easy_cleanup(http_handle2);

return 0;

并获得控制台输出:

  • Rebuilt URL to: http://216.58.208.46/
  • Hostname was NOT found in DNS cache
  • Trying 216.58.208.46...
  • Rebuilt URL to: http://213.180.204.62/
  • Hostname was NOT found in DNS cache
  • Trying 213.180.204.62...

如果我使用curl_easy_perform,但是我不使用curl_multi_perform,那么一切都可以正常工作,所以libcurl中是否存在错误或我做错了什么?我的libcurl版本是7.37.1

everything works perfectly if i use curl_easy_perform but i not with curl_multi_perform so is there a bug in libcurl or I'm doing something wrong ? my libcurl version is 7.37.1

推荐答案

您似乎误解了

You seem to have misunderstood how curl_multi_perform works. It only does a very small piece of the transfer and then returns, and you need to keep calling it until all the transfers are done. (Not in a busy-loop, you should also wait for "action" before you call it again.)

multi- double 在curl网站上的示例.

An example code showing two parallel transfers done with the multi interface is the multi-double example on the curl web site.

在DNS缓存中找不到的有关文本只是垃圾邮件,在以后的版本中将被删除,而重建"文本仅通知您libcurl如何自动为您修复URL,并逐步使用该修复版本. 尝试"部分是libcurl启动到主机的连接,但是由于您再也没有调用它,因此它无法完成其工作!

The texts about not found in the DNS cache is just junk and is removed in a future version, and the "rebuild" text just informs you how libcurl fixed the URL for you automatically and that it uses that fixed version going forward. The "Trying" part is libcurl starting the connect to the hosts but since you never call it again, it can't finish its job!

这篇关于在DNS缓存中找不到Libcurl主机名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆