curl-library
multi interface + writeDataCallback doesn't work on win32 !
Date: Fri, 21 May 2004 10:16:55 +0200
Hi !
First: I'am a newbie in programming with libcurl.
My Problem:
I want to use libcurl's multi interface for asynchronous data downloading
inside my ActiveX control which is embeded in a html document.
Yes I know. The win32 API provides also a downloading mechanism
(URLMonikers) which is documented as asyncronous. But it's syncronous... and
blocks my cotrol. That's bad and therefor I want to use libcurl.
When I use easy handles the writeDataCallback() is called correct. But If I
use multi handles the writeDataCallback() is not called. I set a breakpoint
inside writeDataCallback() but the debugger doesn't stop there (maybe the
multi interface is threaded).
I use VisualStudioC++6.0, downloaded/installed the libcurl package
(libcurl.dll, libcurl.lib) and openSSL package.
Here some code:
void startRequest()
{
DataInfo* data1 = new DataInfo();
CURLMcode code;
curlHandle = curl_multi_init();
CURL* curl1 = curl_easy_init();
// set options
curl_easy_setopt(curl1, CURLOPT_URL, "http://myserver/test.vsm");
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
do {
code = curl_multi_perform(curlHandle, &runningHandles);
}
while (code == CURLM_CALL_MULTI_PERFORM);
}
size_t writeDataCallback(void *buffer, size_t size, size_t nmemb, void
*userp)
{
int realsize = size * nmemb;
// print debug info
OutputDebugString("writeDataCallback() \n");
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;
}
Have anybody an idea what's going wrong ?
Thanks
-steve'o
_________________________________________________________________
E-Mails sind Ihnen nicht schnell genug? http://www.msn.de/messenger MSN
Messenger - Kommunikation in Echtzeit
Received on 2004-05-21