1
/*****************************************************************************
3
* Project ___| | | | _ \| |
5
* | (__| |_| | _ <| |___
6
* \___|\___/|_| \_\_____|
8
* $Id: multi-double.c,v 1.3 2002/12/03 12:34:43 bagder Exp $
10
* This is a very simple example using the multi interface.
16
/* somewhat unix-specific */
21
#include <curl/curl.h>
24
* Simply download two HTTP files!
26
int main(int argc, char **argv)
32
int still_running; /* keep number of running handles */
34
http_handle = curl_easy_init();
35
http_handle2 = curl_easy_init();
38
curl_easy_setopt(http_handle, CURLOPT_URL, "http://www.haxx.se/");
41
curl_easy_setopt(http_handle2, CURLOPT_URL, "http://localhost/");
43
/* init a multi stack */
44
multi_handle = curl_multi_init();
46
/* add the individual transfers */
47
curl_multi_add_handle(multi_handle, http_handle);
48
curl_multi_add_handle(multi_handle, http_handle2);
50
/* we start some action by calling perform right away */
51
while(CURLM_CALL_MULTI_PERFORM ==
52
curl_multi_perform(multi_handle, &still_running));
54
while(still_running) {
55
struct timeval timeout;
56
int rc; /* select() return code */
67
/* set a suitable timeout to play around with */
71
/* get file descriptors from the transfers */
72
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
74
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
82
/* timeout or readable/writable sockets */
83
while(CURLM_CALL_MULTI_PERFORM ==
84
curl_multi_perform(multi_handle, &still_running));
89
curl_multi_cleanup(multi_handle);
91
curl_easy_cleanup(http_handle);
92
curl_easy_cleanup(http_handle2);