cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: CURL POST operation using read and write threads

From: Senthil Raja Velu <Senthil.Raja_at_ss8.com>
Date: Mon, 2 Feb 2009 11:25:57 -0800

Thanks for the pointers Dan!

-Senthil.

-----Original Message-----
From: curl-library-bounces_at_cool.haxx.se
[mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Dan Fandrich
Sent: Friday, January 30, 2009 7:45 PM
To: curl-library_at_cool.haxx.se
Subject: Re: CURL POST operation using read and write threads

On Fri, Jan 30, 2009 at 07:02:23PM -0800, Senthil Raja Velu wrote:
> I am newbie to curl and trying to figure out how to use it with multi
threads.
> I need to perform a POST operation with XML content using a multi
threaded
> program. I need to perform the request operation in one thread and
read the
> response in another thread. I see the curl_easy_perform does it all on
one
> operation. But how do we make the write operation in one thread and
read
> operation in another. Any help is greatly appreciated.

Simple: you don't. libcurl, by definition, performs a single transfer
within
a single thread. If you need access to the results from another thread,
you can grant that access in a few ways. One is to simply download the
data
entirely into memory or disk and pass a pointer or file name to the
other thread. Another is to pass each chunk of data as it is received
to
the other thread from within the write callback function. That is
essentially
the same as the first method just done more frequently (every few KB
instead
of once per URL). Either way, you'll of course have to use some kind
of mutual exclusion method to make sure that both threads don't try to
write
into the same buffer at the same time.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address
service
          Let webmasters know that your web site has moved
Received on 2009-02-02