cURL / Mailing Lists / curl-library / Single Mail


Re: Many easy handles, one socket?

From: Matthew Veenstra <>
Date: Mon, 23 Apr 2007 19:37:41 -0700


Your easiest solution in a situation like this is to just reuse the
easy connection. You can still use you object oriented approach but
it needs to change just a bit.

I assume today you look something like this. (Abstracted for no
programming language in the world :)

someCurlData = new CurlBit;

Now instead of calling the above for every time you need to grab data
just keep a collection or linked list of the connections you want in
a global or application construct. When you want to reuse a
connection search the collection for a connection that is not busy
(this assumes each connection is on its own thread since it locks
otherwise). Add some method like. someCurlData.IsBusy(); if it
returns true look for the next. If no results are found...create a
new instance and append it to the collection.

Now when you application closes call Teminate(...); for each item in
the collection.

If you where to switch to a multi or hyper interface I think you need
to do the same management as described above.

Hopefully someone will correct me if I am wrong here.


On Apr 23, 2007, at 7:02 PM, Nick Zitzmann wrote:

> I've got an object-oriented program. One of these objects holds a
> single CURL easy handle. Each instance of these objects are used
> only once, whenever we want to make a network connection. After the
> connection is done, the instance is deallocated.
Received on 2007-04-24