cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: easy API: curl_easy_perform() doesn't return after receiving all data

From: James Buchanan <software.au_at_gmail.com>
Date: Mon, 13 Nov 2006 07:25:22 +1100

> > The read function is actually what is called when data is sent from
> > the server to the application, is that correct?
>
> Nope. The read function is what libcurl calls in your function when data
> should be read from your system to get sent to the remote server.

The documentation seems to be ambiguous. Here is what it says for
CURLOPT_READFUNCTION in
/curl-7.16.0/docs/libcurl/curl_easy_setopt.html in the curl-7.16.0.zip
package:

=====
CURLOPT_READFUNCTION

Function pointer that should match the following prototype: size_t
function( void *ptr, size_t size, size_t nmemb, void *stream); This
function gets called by libcurl as soon as it needs to read data in
order to send it to the peer.

<snip>
=====

I read that as "This function gets called by libcurl as soon as it
needs to read data in order to upload it to some server elsewhere..."
I took "peer" to mean server elsewhere, not "here" as in the
application using libcurl.

Thanks for clearing that up.

> > And the write function is what is called when libcurl needs the POST data to
> > send to the server
>
> ... the write function is then the function you provide that writes data to a
> local entity (file, memory area or whatever).

Cheers.

> Well, what do you want it to init? I believe these options are documented.

They are, but I was having problems on Win32 so I thought I'd ask just
to cover all the bases that I might have gotten wrong or
misunderstood.

Is it possible CURLOPT_READFUNCTION will be called multiple times, or
do the callbacks get executed only once, when curl has all the data it
can get by seeing Content-Length: or the chunked numbers?

Thanks again,
-J
Received on 2006-11-12