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