curl-library
Re: curl_multi_fdset alternatives
From: Alexander Lazic <al-curllibrary_at_none.at>
Date: Sun, 11 Sep 2005 12:25:27 +0200
Date: Sun, 11 Sep 2005 12:25:27 +0200
On Sam 10.09.2005 12:18, Daniel Stenberg wrote:
>
>No. If the callback gets called with CURL_POLL_IN, it means that your
>application should wait for incoming data on that socket on libcurl's
>behalf and when there is data available you call curl_multi_socket()
>accordingly.
>
>CURL_POLL_OUT is then the same but for a socket that waits to become
>writable, and CURL_POLL_INOUT for a socket that wants to both read and
>write.
>
>But your app doesn't know how to read or write to those sockets as they
>are controlled by libcurl.
Ok i try to make a little pseudo prog:
--- struct apps{ int fd; /* the socket of the handler */ CURL *easy_h; /* the curl easy handler */ }; CURLM *multi_h; int curl_socket_callback(CURL *easy, /* easy handle */ curl_socket_t s, /* socket */ int what, /* Why i was called */ long ms, /* timeout for wait */ void *userp); /* "private" pointer */ { switch(what){ case CURL_POLL_IN: do_somthing_read_* (s,...); break; case CURL_POLL_OUT: do_somthing_write_* (s,...); break; case CURL_POLL_INOUT: do_somthing_both_* (s,...); break; case CURL_POLL_REMOVE: do_somthing_remove_*(s,...); break; case CURL_POLL_NONE: default: $OUT; } /* end of switch */ retrun 0; } /* end of callback */ do_somthing_read_*(curl_socket_t s,...){ sockets_with_events = $CALL_LIBCALL_TO_CHECK_EVENTS_ON_FDS(); for(i < NUMM_OF_sockets_with_events) curl_multi_socket(multi_h,i,NULL,curl_socket_callback,NULL); /* or what ever the user prefer */ for(i < NUMM_OF_sockets_with_events) curl_multi_socket(multi_h,NULL,my_s[i].easy_h,curl_socket_callback,NULL); } /* end do_somthing_read_* */ main{ struct apps my_s[N]; my_s[0].easy_h = curl_easy_init(); my_s[1].easy_h = curl_easy_init(); my_s[N].easy_h = curl_easy_init(); multi_h = curl_multi_init(); for(i=0; i <= N; i++) curl_multi_add_handle(multi_h,my_s[i].easy_h); curl_multi_socket_all(multi_h,curl_socket_callback,NULL); and now the cleanups } --- Have you think about somthing like this? >I do my best in trying to explain how it is planned to work. Yes an thanx for your patience ;-) al ;-)Received on 2005-09-11