cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: opened sockets

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 2 Apr 2002 15:38:13 +0200 (MET DST)

On Tue, 2 Apr 2002, Giaslas Georgios wrote:

> i'd like to ask how libcurl manages the opened sockets in the case of HTTP
> keepalive protocol. After the request has ended how long the socket remain
> opened for? Does libcurl uses some timeout mechanism to close it after 60
> seconds for example or waits for the webserver to closes them?

libcurl opens connections and use them, it then leaves them "open" when
curl_easy_perform() is done, in case there is a subsequent call that can
re-use the same connection again. In this manner, it keeps up to N
simultaneous connections "alive". They are all closed when
curl_easy_cleanup() is used.

At any given point the server side may close a connection in the cache, while
libcurl thinks it is still alive, and thus libcurl checks to see if the
connection is still alive before simply re-using it.

Even if the connection is closed, a second cache is kept for SSL session IDs
which make re-connecting to the same host much faster when using SSL (HTTPS).

A third cache keeps the host name resolves, which makes subsequent DNS
lookups within a given time use the cached result instead of redoing the name
lookup. Therefor, this also usually makes reconnects a lot faster.

I hope this answered your question!

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-04-02