cURL / Mailing Lists / curl-library / Single Mail


libcurl callback order

From: Erik Earle <>
Date: Wed, 25 May 2011 11:04:06 -0700 (PDT)

I'm new to this and I'm looking at the samples, docs and list archives... I
cannot find definitive information on whether 'curl_easy_perform' always returns
after all the calls to 'recv_hdr' and 'recv_data' have returned or if the call
backs are multi-threaded.

Is it the same for the share and multi interfaces as the easy?

// the header call back function
size_t recv_hdr( void *ptr, size_t size, size_t nmemb, void *userdata) { //
receive header line }

// the body call back function
static size_t recv_data(void *ptr, size_t size, size_t nmemb, void *data) {
 // receive body data }

// the main CURL call
void callUrl() {

    CURL *curl;
    CURLcode resp;
    CurlContinuationData *pCurlData = new CurlContinuationData(); // a struct
for data

    curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_URL,

        // set body call back function
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, recv_data);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, pCurlData);
        // set header call back function curl_easy_setopt(curl,
        curl_easy_setopt(curl, CURLOPT_HEADERDATA, pCurlData);
        resp = curl_easy_perform(curl);



List admin:
Received on 2011-05-25