curl-library
Re: SO_REUSEADDR and multi-threaded environment
Date: Wed, 2 Jul 2014 10:00:32 -0400
Hi Yehezkel
Each thread in my client application creates a CURL handle using
curl_easy_init, sends a request to the server and once the response is
received, invokes curl_easy_cleanup on the handle. So, the connection is
closed by the thread owning the CURL handle on the client side. I am
invoking curl_easy_cleanup because I am under impression that each CURL
handle manages its own connection and they are not shared across CURL
handles. Can CURL handles share underlying connections? According to the
doc, CURL handles should not be shared across threads at the same time
which made me believe that the underlying connections won't be either.
Even if the connections are closed by each thread, I was hoping that I
would still be able to reuse ports in TIME_WAIT state using the
SO_REUSEADDR and CURLOPT_SOCKOPTFUNCTION and wanted to get some feedback on
that strategy.
Thanks
Sachin
On Wed, Jul 2, 2014 at 3:25 AM, Yehezkel Horowitz <horowity_at_checkpoint.com>
wrote:
> > After a request, connection is closed by each thread. I see that a lot
> of ports are being left in TIME_WAIT state after running my application
> which I can understand.
> Why the connection is closed after a request and by whom?
> Did the server return "Connection: close" or send FIN/RST?
> Did you set FORBID_REUSE option?
>
> You can also try adding some more IP addresses to the server (DNS
> round-robin) and get a bigger range of IP:port.
>
> HTH
>
> Yehezkel Horowitz
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-07-02