cURL / Mailing Lists / curl-library / Single Mail

curl-library

How to cleanly close the curl socket in case of multi interface?

From: nikhil ap <niks3089_at_gmail.com>
Date: Fri, 19 Sep 2014 16:52:48 +0530

I have setup the connection context similar to the one given the
example hiperfifo.c which is a structure contains a pointer to the easy
handle, url, socket info and other application stuff and stats.

I have created 10 TCP connections by adding 10 easy handles to multi
handle.
After a connection is done with some requests lets about 100, I would like
to close the connection and TCP socket by sending a FIN.

When the connection needs to be cleaned up, I do calls to

curl_multi_remove_handle()
curl_easy_cleanup()

but this does not close the TCP connection and eventually the connection
gets a FIN from server side after keepalive timeout or if clients sends a
FIN after the test when I do curl_multi_cleanup().

I do like to keep the connection persistent in some cases and close in some
other.

As a work around, when I have to cleanup the connection, I do close on curl
socket which triggers a FIN.

Is there a better way to close the socket?

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