2 * This is a simple example using the multi interface.
8 /* somewhat unix-specific */
12 /* To start with, we include the header from the lib directory. This should
13 later of course be moved to the proper include dir. */
14 #include "../lib/multi.h"
17 * Simply download two HTTP files!
19 int main(int argc, char **argv)
25 int still_running; /* keep number of running handles */
27 http_handle = curl_easy_init();
28 http_handle2 = curl_easy_init();
31 curl_easy_setopt(http_handle, CURLOPT_URL, "http://www.haxx.se/");
34 curl_easy_setopt(http_handle2, CURLOPT_URL, "http://localhost/");
36 /* init a multi stack */
37 multi_handle = curl_multi_init();
39 /* add the individual transfers */
40 curl_multi_add_handle(multi_handle, http_handle);
41 curl_multi_add_handle(multi_handle, http_handle2);
43 /* we start some action by calling perform right away */
44 while(CURLM_CALL_MULTI_PERFORM ==
45 curl_multi_perform(multi_handle, &still_running));
47 while(still_running) {
48 struct timeval timeout;
49 int rc; /* select() return code */
60 /* set a suitable timeout to play around with */
64 /* get file descriptors from the transfers */
65 curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
67 rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
75 /* timeout or readable/writable sockets */
76 curl_multi_perform(multi_handle, &still_running);
81 curl_multi_cleanup(multi_handle);
83 curl_easy_cleanup(http_handle);
84 curl_easy_cleanup(http_handle2);