cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Write callback compared to progress callback

From: Andreas Volz <lists_at_brachttal.net>
Date: Wed, 9 Jan 2008 19:01:02 +0100

Am Tue, 8 Jan 2008 23:51:02 +0100 (CET) schrieb Daniel Stenberg:

> On Tue, 8 Jan 2008, Andreas Volz wrote:
>
> > I use a write and a progress callback in my application. I'm
> > wondering that the progress callback runs several time even that it
> > has yet 100% downloaded. The write callback isn't called then.
>
> [..]
>
> > Downloaded 7200 bytes of total 8008 bytes (89.910090%)
> > write: 808
> >
> > Downloaded 8008 bytes of total 8008 bytes (100.000000%)
> >
> > Downloaded 8008 bytes of total 8008 bytes (100.000000%)
> >
> > Any ideas why this happens?
>
> Uhm.... no! ;-O

I found the reason:

> CURLOPT_PROGRESSFUNCTION
>
> Function pointer that should match the curl_progress_callback
> prototype found in <curl/curl.h>. This function gets called by
> libcurl instead of its internal equivalent with a frequent interval
> during operation (roughly once per second) no matter if data is being
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
> transfered or not. Unknown/unused argument values passed to the
^^^^^^^^^^^^^^^^^^^
> callback will be set to zero (like if you only download data, the
> upload size will remain 0). Returning a non-zero value from this
> callback will cause libcurl to abort the transfer and return
> CURLE_ABORTED_BY_CALLBACK.
>
> If you transfer data with the multi interface, this function will not
> be called during periods of idleness unless you call the appropriate
> libcurl function that performs transfers.
>

This explains much :-)

regards
Andreas
Received on 2008-01-09