cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Read and write on the same cURL handle

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 26 Jun 2014 05:08:22 +0200 (CEST)

On Mon, 23 Jun 2014, Richard W.M. Jones wrote:

(had to handicraft the reply due to unimportant stuff, so this reply may not
be threaded as nicely as it should've been)

> On Mon, Jun 23, 2014 at 10:44:17AM +0100, Richard W.M. Jones wrote:
>> Can a single cURL handle be "switched" between reading and uploading?
>> And if so, how do you do that?
>>
>> Or should the plugin open two handles (one for reading, one for
>> writing)?
>
> Or a third option: Should the plugin open a new cURL handle for every
> request?
>
> Or a fourth: Keep open a collection of cURL handles? (And if so, what
> policy to use to decide when to open a new handle or close an old one?)
>
> Note that NBD pread & pwrite requests are generally quite small, frequent,
> and of course unpredictable in both size, frequency and order.

A curl handle can be re-used for any amount of requests so a read (download)
request can very well be followed by a write (upload) request. But they are
then two subsequent requests and you can't just switch at will at a random
point in time.

As I don't really know what you'd use the writing and reading for, I don't
think I can advice very good here.

A general rule is that curl handles should be kept around and re-used for
subsequent requests as much as possible for best performance.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2014-06-26