cURL / Mailing Lists / curl-library / Single Mail

curl-library

grokking 10000 multi connections

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Wed, 16 Feb 2005 00:13:01 +0100 (CET)

Hi

I read all the mails in the threads talking about the updated multi API, and
I'm not sure we've landed something complete just yet. Please read through
this mail and post your feedback.

The new public API for the multi interface is being designed to allow libcurl
to perform good even with a huge amount of connections - and to allow the app
to use whatever poll/select method it pleases. The point being that the API
should not be a limitation (to a reasonable degree), only the actual
implementation.

  curl_multi_sockset() - Sets a callback that gets called... eh, when there's
                          new file descriptor/change to wait for. The
                          callback's signature might be as previously
                          discussed. I leave that out from here for now.

  curl_mulit_sockupd() - Request an update of the socket (file descriptor)
                          status, by getting the callback called updating the
                          status properly since the previous time this function
                          was used.

  curl_multi_sockperf() - A new version of curl_multi_perform() that allows
                          the application to (somehow) pass on a list of what
                          file descriptors that were detected to have "action"
                          on them, to allow libcurl to not have to scan through
                          all possible file descriptors to check for this.

In an appplication that uses 10000 simultaneous transfers, it would do
something like this in the main loop:

----------- pseudo code example app ---------------

  curl_multi_sockset(... set up to use our socket callback)

  while ( still_running ) {

    curl_multi_sockupd() /* get the callback called multiple times so that we
                            know what to wait for */

    /* Wait for action, on libcurl's sockets and on our own set of things.
       This can use select(), poll() or whatever high-performance polling
       function your particular OS provides */

    wait( ); /* ... with a timeout */

    /* When the wait is done, either by an action or by a timeout

    curl_multi_sockperf(); /* this should pass on information to libcurl about
                              what file descriptors that have "action" */

  }

---------------- end of example --------------------

-- 
      Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
       Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2005-02-16