cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: need example of curl_multi_socket_all

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 27 Jul 2007 23:12:58 +0200 (CEST)

On Fri, 27 Jul 2007, maodong hu wrote:

PLEASE don't top-post!

> because I use the 7.16.4, it added new interface curl_multi_socket_all and
> curl_multi_socket_action, the document said it used to replace
> curl_multi_perform and not forced to use select, but I can not find any
> examples in the curl-7.16.4.zip that show how to use these two function.

docs/examples/hiperfifo.c does!

And the *socket() API does not really "replace" curl_multi_perform(), it is an
alternative function to use in case you find curl_multi_perform() too
restrictive.

> 1. Create a multi handle
> 2. Set the socket callback with CURLMOPT_SOCKETFUNCTION
> 3. Add easy handles
> 4. Call curl_multi_socket_all() first once
> 5. Setup a "collection" of sockets to supervise when your socket callback is
> called.
> 6. Use curl_multi_timeout() to figure out how long to wait for action
> 7. Wait for action on any of libcurl's sockets
> 8, When action happens, call curl_multi_socket_action() for the socket(s)
> 9. Go back to step 6.

> but I can not make a idea from this describe, so I want a examples to show
> me how to use it.

As you can see in the hiperfifo.c example, it quickly becomes rather complex
as using the multi_socket() API is powerful but requires a fair amount of code
to make it work fine.

Also, if the above description is not enough, can you please tell me more
specificly what details in that list that need to be extended? When I read it
now again, I think it is a perfect short description on how to use the API...

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2007-07-27