1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
12 #include <sys/types.h>
22 * 3. with multi interface
28 CURL *handle = NULL, *duphandle;
29 CURLM *mhandle = NULL;
31 int still_running = 0;
33 if(curl_global_init(CURL_GLOBAL_ALL)) {
34 fprintf(stderr, "curl_global_init() failed\n");
38 handle = curl_easy_init();
40 res = CURLE_OUT_OF_MEMORY;
44 test_setopt(handle, CURLOPT_URL, URL);
45 test_setopt(handle, CURLOPT_WILDCARDMATCH, 1L);
46 test_setopt(handle, CURLOPT_VERBOSE, 1L);
48 res = curl_easy_perform(handle);
52 res = curl_easy_perform(handle);
56 duphandle = curl_easy_duphandle(handle);
59 curl_easy_cleanup(handle);
62 mhandle = curl_multi_init();
64 fprintf(stderr, "curl_multi_init() failed\n");
68 curl_multi_add_handle(mhandle, handle);
70 while(CURLM_CALL_MULTI_PERFORM ==
71 curl_multi_perform(mhandle, &still_running));
73 while(still_running) {
74 static struct timeval timeout = /* 100 ms */ { 0, 100000L };
84 m = curl_multi_fdset(mhandle, &fdread, &fdwrite, &fdexcep, &max_fdset);
86 fprintf(stderr, "curl_multi_fdset() error\n");
89 /* We call select(max_fdset + 1, ...), specially in case of (maxfd == -1),
90 * we call select(0, ...), which is basically equal to sleep. */
91 rc = select(max_fdset + 1, &fdread, &fdwrite, &fdexcep, &timeout);
93 fprintf(stderr, "select() error\n");
97 while(CURLM_CALL_MULTI_PERFORM ==
98 curl_multi_perform(mhandle, &still_running));
104 curl_multi_cleanup(mhandle);
106 curl_easy_cleanup(handle);
107 curl_global_cleanup();