Harry
Harry

Reputation: 344

Libcurl Hostname was NOT found in DNS cache

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;

and get console output:

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

Upvotes: 2

Views: 1379

Answers (1)

Daniel Stenberg
Daniel Stenberg

Reputation: 58034

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.)

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

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!

Upvotes: 2

Related Questions