2
我試圖用curl_multi 2並聯:libcurl的主機名未在DNS高速緩存中找到
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;
,並得到控制檯輸出:
- 重建網址:http://216.58.208.46/
- 主機名是不是在DNS緩存中找到
- 試用216.58.208.46 ...
- 重建網址爲:http://213.180.204.62/
- 主機名未在DNS高速緩存中找到
- 試圖213.180.204.62 ...
一切完美,如果我使用curl_easy_perform但我不curl_multi_perform所以是有libcurl中的錯誤或我做錯了什麼?我的libcurl版本是7.37.1