aboutsummaryrefslogtreecommitdiffstats
path: root/docs/examples/multi-app.c
diff options
context:
space:
mode:
Diffstat (limited to 'docs/examples/multi-app.c')
-rw-r--r--docs/examples/multi-app.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/docs/examples/multi-app.c b/docs/examples/multi-app.c
index b8258975..f8447930 100644
--- a/docs/examples/multi-app.c
+++ b/docs/examples/multi-app.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at http://curl.haxx.se/docs/copyright.html.
+ * are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -19,7 +19,11 @@
* KIND, either express or implied.
*
***************************************************************************/
-/* This is an example application source code using the multi interface. */
+/* <DESC>
+ * A basic application source code using the multi interface doing two
+ * transfers in parallel.
+ * </DESC>
+ */
#include <stdio.h>
#include <string.h>
@@ -51,8 +55,8 @@ int main(void)
int msgs_left; /* how many messages are left */
/* Allocate one CURL handle per transfer */
- for (i=0; i<HANDLECOUNT; i++)
- handles[i] = curl_easy_init();
+ for(i=0; i<HANDLECOUNT; i++)
+ handles[i] = curl_easy_init();
/* set the options (I left out a few, you'll get the point anyway) */
curl_easy_setopt(handles[HTTP_HANDLE], CURLOPT_URL, "http://example.com");
@@ -64,8 +68,8 @@ int main(void)
multi_handle = curl_multi_init();
/* add the individual transfers */
- for (i=0; i<HANDLECOUNT; i++)
- curl_multi_add_handle(multi_handle, handles[i]);
+ for(i=0; i<HANDLECOUNT; i++)
+ curl_multi_add_handle(multi_handle, handles[i]);
/* we start some action by calling perform right away */
curl_multi_perform(multi_handle, &still_running);
@@ -102,8 +106,7 @@ int main(void)
/* get file descriptors from the transfers */
mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
- if(mc != CURLM_OK)
- {
+ if(mc != CURLM_OK) {
fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc);
break;
}
@@ -142,12 +145,12 @@ int main(void)
} while(still_running);
/* See how the transfers went */
- while ((msg = curl_multi_info_read(multi_handle, &msgs_left))) {
- if (msg->msg == CURLMSG_DONE) {
+ while((msg = curl_multi_info_read(multi_handle, &msgs_left))) {
+ if(msg->msg == CURLMSG_DONE) {
int idx, found = 0;
/* Find out which handle this message is about */
- for (idx=0; idx<HANDLECOUNT; idx++) {
+ for(idx=0; idx<HANDLECOUNT; idx++) {
found = (msg->easy_handle == handles[idx]);
if(found)
break;
@@ -167,8 +170,8 @@ int main(void)
curl_multi_cleanup(multi_handle);
/* Free the CURL handles */
- for (i=0; i<HANDLECOUNT; i++)
- curl_easy_cleanup(handles[i]);
+ for(i=0; i<HANDLECOUNT; i++)
+ curl_easy_cleanup(handles[i]);
return 0;
}