cURL / Mailing Lists / curl-library / Single Mail


Re: v8 --enable-dream-mode

From: Daniel Stenberg <>
Date: Wed, 19 Dec 2001 09:36:54 +0100 (MET)

On Tue, 18 Dec 2001, Andrés García wrote:

> Would it be possible to add a configure option so that curl_easy_perform
> behaves in a non-blocking way?

I doubt we'll ever make curl_easy_perform non-blocking. I believe in keeping
the easy interface as easy as it is now. I think the added multi interface
and how that is using one or more setups of easy-connections make everything
really nicely glued together.

> The problem I have is that if I use TclCurl in a Tcl/Tk program, the GUI of
> the program freezes during the transfer, I have tried defining a callback
> function with CURLOPT_PROGRESSFUNCTION and manually forcing the update from
> it, but the result doesn't seem to be responsive enough.

You should probably consider doing the transfer in a separate thread.

> I guess it can also be solved using the new multi interface (which I will
> try to test as soon as possible), but doing it with the easy API, if
> possible, looks simpler.

The multi interface is what gonna offer asynchronous, non-blocking function
calls for file transfers. Transferring single files using the multi interface
is gonna be very easy, quite similar to how the easy interface is used. You
basicly just need to call the same function over and over again until it says
it has completed its operation.

Let me show you the easiest possible file retrieving example. This goes only
to show the most basic mechanisms, it does a bit of busy-looping that won't
be nice, and the variables are not declared properly:

  http_handle = curl_easy_init();
  curl_easy_setopt(http_handle, CURLOPT_URL, "");

  multi_handle = curl_multi_init();

  curl_multi_add_handle(multi_handle, http_handle);

  do {
    /* place for your own code */
    curl_multi_perform(multi_handle, &still_running);
  } while(still_running);



    Daniel Stenberg -- curl groks URLs --
Received on 2001-12-19