cURL / Mailing Lists / curl-library / Single Mail

curl-library

How to explicitly close underlying TCP connection in libcurl

From: ajil koshy <ajil.koshy_at_gmail.com>
Date: Fri, 25 Mar 2011 19:31:22 +0530

Hi,

I am writing an HTTPS client using libcurl/OpenSSL. The client is expected
to periodically connect to the server, exchange data and close the
connection i.e. not keep a persistent connection. What would be the best way
to explicitly close the underlying TCP connection from the client side
without having to close the libcurl handle? I want to keep the Libcurl
handle alive in order to leverage the SSL session cache. I currently see two
options.

a) Using undocumented function Curl_disconnect ()
b) Limit CURLOPT_MAXCONNECTS to 1 and use CURL_OPT_CONNECT_ONLY: To
disconnect, we can change the URL on the CURL handle and simply call call
curl_easy_perform ().

Do you think either of the above is a nice way (probably not :-) ) to do it?
Can you suggest the right way to do this?

Thanks
Ajil Koshy

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-03-25