cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Andy Hobbs <andy.hobbs_at_ramesystravel.co.uk>
Date: Wed, 19 May 2004 15:37:38 +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 Hobbs                        -
- SABS Developer                    -
- Ramesys Travel Ltd                -
- t. 0161 941 1307                  -
- w. www.ramesys.com/travel         -
- e. andy.hobbs_at_ramesystravel.co.uk -
-------------------------------------
Received on 2004-05-19