cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: multi interface + writeDataCallback doesn't work on win32 !

From: Andy Hobbs <andy_at_trogs.org.uk>
Date: Wed, 19 May 2004 15:09:42 +0100

Try this

while (curl_multi_perform(curlHandle, &runningHandles) ==
CURLM_CALL_MULTI_PERFORM)

Andy

On Wed, 2004-05-19 at 14:59, Stefan Libcurl wrote:
> 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.

-- 
andy_at_trogs.org.uk
I'd like to meet the guy who invented beer and see what he's working on
now
Received on 2004-05-19