curl-library
multi interface + writeDataCallback doesn't work on win32 !
Date: Wed, 19 May 2004 15:59:33 +0200
Hi !
I'am a newbie in libcurl and tried to use the multi interface of libcurl.
I want to pull several files from a server without blocking my application.
It's an ActiveX control embeded in html for running in IE. I know there are
also a win32 API, but it blocks !!
I followed the docs how to declare a writeDataCallback function.
Great, when I use an libcurl easy handle my callback function is called.
Using a multi handler the callback funtion is never called.
If I set an breakpoint into callback funtion the debugger is not stopped.
Maybe it's a problem of multi-threadig ?
Here a snipped code:
{
...
DataInfo* data1 = new DataInfo();
curlHandle = curl_multi_init();
CURL* curl1 = curl_easy_init();
// set options
curl_easy_setopt(curl1, CURLOPT_URL, "http://myserver/dach_all.vsp");
curl_easy_setopt(curl1, CURLOPT_WRITEFUNCTION, ::writeDataCallback);
curl_easy_setopt(curl1, CURLOPT_WRITEDATA, (void *)data1);
curl_easy_setopt(curl1, CURLOPT_PROXYAUTH, CURLAUTH_BASIC | CURLAUTH_NTLM
);
// add easy handles to multi handle
curl_multi_add_handle(curlHandle, curl1);
// perform
code = curl_multi_perform(curlHandle, &runningHandles);
}
and here the callback:
size_t writeDataCallback(void *buffer, size_t size, size_t nmemb, void
*userp)
{
int realsize = size * nmemb;
DataInfo* info = (DataInfo*)userp;
info->memory = (char *)realloc(info->memory, info->size + realsize + 1);
if (info->memory)
{
memcpy(&(info->memory[info->size]), buffer, realsize);
info->size += realsize;
info->memory[info->size] = 0;
}
return realsize;
}
With an easy handle it works. Have anybody an idea ?
Thanks
-steve'o
_________________________________________________________________
Schluß mit Spam! http://www.msn.de/antispam/prevention/junkmailfilter Wir
helfen Ihnen, unerwünschte E-Mails zu reduzieren.
Received on 2004-05-19