aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorConstantine Sapuntzakis <csapuntz@gmail.com>2010-07-14 00:32:53 +0200
committerDaniel Stenberg <daniel@haxx.se>2010-07-14 00:32:53 +0200
commitbc0699f226ec55fde58a823fb818d8f8106c8fbd (patch)
tree844efe753cd308473c8eca25b6d0bfce23925cf3 /docs
parent157e6d4e7e4f3d5eff4fea7ba7fe840da5fcfd63 (diff)
examples: add curl_multi_timeout
Make the multi-interface using examples use curl_multi_timeout to properly educate users how to do things.
Diffstat (limited to 'docs')
-rw-r--r--docs/examples/fopen.c11
-rw-r--r--docs/examples/multi-app.c11
-rw-r--r--docs/examples/multi-debugcallback.c11
-rw-r--r--docs/examples/multi-double.c11
-rw-r--r--docs/examples/multi-post.c11
-rw-r--r--docs/examples/multi-single.c11
6 files changed, 66 insertions, 0 deletions
diff --git a/docs/examples/fopen.c b/docs/examples/fopen.c
index 35e24b11f..f21526b29 100644
--- a/docs/examples/fopen.c
+++ b/docs/examples/fopen.c
@@ -144,6 +144,8 @@ fill_buffer(URL_FILE *file,int want,int waittime)
do
{
int maxfd = -1;
+ long curl_timeo = -1;
+
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
@@ -152,6 +154,15 @@ fill_buffer(URL_FILE *file,int want,int waittime)
timeout.tv_sec = 60; /* 1 minute */
timeout.tv_usec = 0;
+ curl_multi_timeout(multi_handle, &curl_timeo);
+ if(curl_timeo >= 0) {
+ timeout.tv_sec = curl_timeo / 1000;
+ if(timeout.tv_sec > 1)
+ timeout.tv_sec = 1;
+ else
+ timeout.tv_usec = (curl_timeo % 1000) * 1000;
+ }
+
/* get file descriptors from the transfers */
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
diff --git a/docs/examples/multi-app.c b/docs/examples/multi-app.c
index 38b50cd0d..bcc9f393a 100644
--- a/docs/examples/multi-app.c
+++ b/docs/examples/multi-app.c
@@ -68,6 +68,8 @@ int main(int argc, char **argv)
fd_set fdexcep;
int maxfd = -1;
+ long curl_timeo = -1;
+
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
@@ -76,6 +78,15 @@ int main(int argc, char **argv)
timeout.tv_sec = 1;
timeout.tv_usec = 0;
+ curl_multi_timeout(multi_handle, &curl_timeo);
+ if(curl_timeo >= 0) {
+ timeout.tv_sec = curl_timeo / 1000;
+ if(timeout.tv_sec > 1)
+ timeout.tv_sec = 1;
+ else
+ timeout.tv_usec = (curl_timeo % 1000) * 1000;
+ }
+
/* get file descriptors from the transfers */
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
diff --git a/docs/examples/multi-debugcallback.c b/docs/examples/multi-debugcallback.c
index 8e964c67b..fa90bbc48 100644
--- a/docs/examples/multi-debugcallback.c
+++ b/docs/examples/multi-debugcallback.c
@@ -142,6 +142,8 @@ int main(int argc, char **argv)
fd_set fdexcep;
int maxfd = -1;
+ long curl_timeo = -1;
+
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
@@ -150,6 +152,15 @@ int main(int argc, char **argv)
timeout.tv_sec = 1;
timeout.tv_usec = 0;
+ curl_multi_timeout(multi_handle, &curl_timeo);
+ if(curl_timeo >= 0) {
+ timeout.tv_sec = curl_timeo / 1000;
+ if(timeout.tv_sec > 1)
+ timeout.tv_sec = 1;
+ else
+ timeout.tv_usec = (curl_timeo % 1000) * 1000;
+ }
+
/* get file descriptors from the transfers */
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
diff --git a/docs/examples/multi-double.c b/docs/examples/multi-double.c
index bc5b446ea..8ac939a96 100644
--- a/docs/examples/multi-double.c
+++ b/docs/examples/multi-double.c
@@ -59,6 +59,8 @@ int main(int argc, char **argv)
fd_set fdexcep;
int maxfd = -1;
+ long curl_timeo = -1;
+
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
@@ -67,6 +69,15 @@ int main(int argc, char **argv)
timeout.tv_sec = 1;
timeout.tv_usec = 0;
+ curl_multi_timeout(multi_handle, &curl_timeo);
+ if(curl_timeo >= 0) {
+ timeout.tv_sec = curl_timeo / 1000;
+ if(timeout.tv_sec > 1)
+ timeout.tv_sec = 1;
+ else
+ timeout.tv_usec = (curl_timeo % 1000) * 1000;
+ }
+
/* get file descriptors from the transfers */
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
diff --git a/docs/examples/multi-post.c b/docs/examples/multi-post.c
index 0d3f78e5e..df574ae72 100644
--- a/docs/examples/multi-post.c
+++ b/docs/examples/multi-post.c
@@ -79,6 +79,8 @@ int main(int argc, char *argv[])
fd_set fdexcep;
int maxfd = -1;
+ long curl_timeo = -1;
+
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
@@ -87,6 +89,15 @@ int main(int argc, char *argv[])
timeout.tv_sec = 1;
timeout.tv_usec = 0;
+ curl_multi_timeout(multi_handle, &curl_timeo);
+ if(curl_timeo >= 0) {
+ timeout.tv_sec = curl_timeo / 1000;
+ if(timeout.tv_sec > 1)
+ timeout.tv_sec = 1;
+ else
+ timeout.tv_usec = (curl_timeo % 1000) * 1000;
+ }
+
/* get file descriptors from the transfers */
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
diff --git a/docs/examples/multi-single.c b/docs/examples/multi-single.c
index cba4f32cc..d3f9cfde0 100644
--- a/docs/examples/multi-single.c
+++ b/docs/examples/multi-single.c
@@ -53,6 +53,8 @@ int main(int argc, char **argv)
fd_set fdexcep;
int maxfd = -1;
+ long curl_timeo = -1;
+
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
@@ -61,6 +63,15 @@ int main(int argc, char **argv)
timeout.tv_sec = 1;
timeout.tv_usec = 0;
+ curl_multi_timeout(multi_handle, &curl_timeo);
+ if(curl_timeo >= 0) {
+ timeout.tv_sec = curl_timeo / 1000;
+ if(timeout.tv_sec > 1)
+ timeout.tv_sec = 1;
+ else
+ timeout.tv_usec = (curl_timeo % 1000) * 1000;
+ }
+
/* get file descriptors from the transfers */
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);