curl / Mailing Lists / curl-library / Single Mail


Re: Libcurl handles and file descriptors and select

From: Daniel Stenberg <>
Date: Thu, 12 Oct 2017 14:54:11 +0200 (CEST)

On Thu, 12 Oct 2017, surya chandrika via curl-library wrote:

> -> When is the file descriptors actually associated with a handle.

I'm not sure that's good question. Each handle may have one or more file
descriptors associated with it at any time during its life time. You're better
off not trying to second guess when and when not. It depends entirely on the
state of the transfer(s) that the handle is involved with.

> -> Is there any limitation in the number of handles that can be created by a
> process.

There is no limit enforced by libcurl itself, no, but there are typically
steill some limits that are in place: the maximum number of simultanously open
file descriptors in your process for example. By default on most unix like
systems, that number is 1024 (and I believe even less on Windows). Also, going
beyond 1024 might give you problems if you want to use select() and aren't

But if you intend to use a large number of parallel transfers, you really
should not use select() anyway in the first place.

> 3. multiple threads which in turn will call curl_multi_perform and post to
> remote host.

Just make sure each libcurl-using thread is completely independent or uses
mutexes to ensure that each handle is only ever used by one process at a time:

Received on 2017-10-12