cURL / Mailing Lists / curl-library / Single Mail

curl-library

How to get easy_handle in callback function??

From: Milan Køápek <Hellbard_at_seznam.cz>
Date: Fri, 04 May 2007 15:28:01 +0200 (CEST)

Hi I need help.

I have multithreaded http client. And of cource a lot of requests to one server. I decided to use curl_multi_handle to serves this requests. But I have one problem. When I get response to my request, I need to know, which easy_handle calls the callback function.

I think, I have one reason for it, but I am not sure, so I want ask if this will be working. Here is my code.

int createCurl(){
  CURL* curl;
  curl = curl_easy_init();
  curl_easy_setopt(curl, CURLOPT_URL, urlString);
  curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write);
  curl_easy_setopt(curl CURLOPT_WRITEDATA, (void *)curl);
  
  // add easy_handel to multi handle (global variable)
  curl_multi_add_handle(multi,curl);
}

int write (void *ptr, size_t size, size_t nmemb, void *data){
  // read input stream in *ptr
 CURL* curl = static_cast<CURL*> (data);
}

All I want is to know, If it will work and in method write I have in parametr data, pointer tu CURL object, which I created in createCurl function.

Thanks for response.

Milan Krapek
Received on 2007-05-04