curl-library
Re: multi interface + writeDataCallback doesn't work on win32 !
Date: Wed, 19 May 2004 15:45:15 +0100
Hi,
Sorry was a bit hasty replying 
not quite a complete bit of code, lets try again...
while (curl_multi_perform(curlHandle, &runningHandles) ==
CURLM_CALL_MULTI_PERFORM)
{
}
You need to loop on this until the query is done.  From when I have used
it you need to do this twice, once to send the request and once to
receive the response.
You should also consider doing a select() in between sending and
receiving.
see the below as a good example of this:
http://curl.haxx.se/lxr/source/docs/examples/multi-post.c
Hope this helps
Andy
> On Wed, 2004-05-19 at 15:09, Andy Hobbs wrote:
> > 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 nowReceived on 2004-05-19