summaryrefslogtreecommitdiff
path: root/docs/examples/hiperfifo.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2008-11-19 15:30:41 +0000
committerDaniel Stenberg <daniel@haxx.se>2008-11-19 15:30:41 +0000
commit22d4db1cf2f2661c6d7292c9545051937be25ed2 (patch)
tree30aa1a43d7d60957a05294bef93c6a19bfe2bd5a /docs/examples/hiperfifo.c
parent7383225271fc38c0421f647c8e5fda26161f6079 (diff)
downloadcurl-22d4db1cf2f2661c6d7292c9545051937be25ed2.tar.gz
I updated this example to use the modern paradigms of the socket API where
*_socket_all() and *_socket() aren't used at all but only *_socket_action() is.
Diffstat (limited to 'docs/examples/hiperfifo.c')
-rw-r--r--docs/examples/hiperfifo.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/docs/examples/hiperfifo.c b/docs/examples/hiperfifo.c
index 95ca8ad0d..d19048506 100644
--- a/docs/examples/hiperfifo.c
+++ b/docs/examples/hiperfifo.c
@@ -180,12 +180,17 @@ static void event_cb(int fd, short kind, void *userp)
{
GlobalInfo *g = (GlobalInfo*) userp;
CURLMcode rc;
- (void)kind; /* unused */
+
+ int action =
+ (kind&EV_READ:CURL_CSELECT_IN)|
+ (kind&EV_WRITE:CURL_CSELECT_OUT);
do {
- rc = curl_multi_socket(g->multi, fd, &g->still_running);
+ rc = curl_multi_socket_action(g->multi, fd, action, &g->still_running);
} while (rc == CURLM_CALL_MULTI_PERFORM);
- mcode_or_die("event_cb: curl_multi_socket", rc);
+
+ mcode_or_die("event_cb: curl_multi_socket_action", rc);
+
check_run_count(g);
if ( g->still_running <= 0 ) {
fprintf(MSG_OUT, "last transfer done, kill timeout\n");
@@ -206,9 +211,10 @@ static void timer_cb(int fd, short kind, void *userp)
(void)kind;
do {
- rc = curl_multi_socket(g->multi, CURL_SOCKET_TIMEOUT, &g->still_running);
+ rc = curl_multi_socket_action(g->multi,
+ CURL_SOCKET_TIMEOUT, 0, &g->still_running);
} while (rc == CURLM_CALL_MULTI_PERFORM);
- mcode_or_die("timer_cb: curl_multi_socket", rc);
+ mcode_or_die("timer_cb: curl_multi_socket_action", rc);
check_run_count(g);
}
@@ -337,11 +343,9 @@ static void new_conn(char *url, GlobalInfo *g )
"Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url);
rc =curl_multi_add_handle(g->multi, conn->easy);
mcode_or_die("new_conn: curl_multi_add_handle", rc);
- do {
- rc = curl_multi_socket_all(g->multi, &g->still_running);
- } while (CURLM_CALL_MULTI_PERFORM == rc);
- mcode_or_die("new_conn: curl_multi_socket_all", rc);
- check_run_count(g);
+
+ /* note that the add_handle() will set a time-out to trigger very soon so
+ that the necessary socket_action() call will be called by this app */
}
/* This gets called whenever data is received from the fifo */
@@ -409,13 +413,16 @@ int main(int argc, char **argv)
init_fifo(&g);
g.multi = curl_multi_init();
evtimer_set(&g.timer_event, timer_cb, &g);
+
+ /* setup the generic multi interface options we want */
curl_multi_setopt(g.multi, CURLMOPT_SOCKETFUNCTION, sock_cb);
curl_multi_setopt(g.multi, CURLMOPT_SOCKETDATA, &g);
curl_multi_setopt(g.multi, CURLMOPT_TIMERFUNCTION, multi_timer_cb);
curl_multi_setopt(g.multi, CURLMOPT_TIMERDATA, &g);
- do {
- rc = curl_multi_socket_all(g.multi, &g.still_running);
- } while (CURLM_CALL_MULTI_PERFORM == rc);
+
+ /* we don't call any curl_multi_socket*() function yet as we have no handles
+ added! */
+
event_dispatch();
curl_multi_cleanup(g.multi);
return 0;