在 DNS 缓存中找不到 Libcurl 主机名

Libcurl Hostname was NOT found in DNS cache

我正在尝试与 curl_multi 进行 2 个并行连接:

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;

并获取控制台输出:

如果我使用 curl_easy_perform 但我不使用 curl_multi_perform ,一切都会完美运行,那么 libcurl 中是否存在错误或者我做错了什么?我的 libcurl 版本是 7.37.1

您似乎误解了 curl_multi_perform 的工作原理。它只做一小部分传输然后 returns,你需要一直调用它直到所有传输完成。 (不是在忙循环中,您还应该等待 "action" 后再调用它。)

显示使用多接口完成的两个并行传输的示例代码是 curl 网站上的 multi-double 示例。

关于在 DNS 缓存中找不到的文本只是垃圾,在未来的版本中将被删除,"rebuild" 文本只是告诉您 libcurl 如何自动为您修复 URL,并且它使用该固定版本前进。 "Trying" 部分是 libcurl 开始连接到主机,但由于您再也不会调用它,它无法完成它的工作!