cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: SO_REUSEADDR and multi-threaded environment

From: Sachin Nikumbh <sanikumbh_at_gmail.com>
Date: Mon, 7 Jul 2014 08:38:38 -0400

Hi Daniel,

According to the doc, CURLOPT_SOCKOPTFUNCTION callback gets invoked after
the socket has been created but before call to connect on the socket.
That's why I was using CURLOPT_SOCKOPTFUNCTION. May be I should try
CURLOPT_OPENSOCKETFUNCTION?

Thanks
Sachin

On Wed, Jul 2, 2014 at 5:21 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Tue, 1 Jul 2014, Sachin Nikumbh wrote:
>
> I have a client application that's using libcurl to communicate with a
>> proprietary server. I am testing the application in multi-threaded
>> environment and how it scales with the number of threads.
>>
>
> I don't think this is really related to multi threading though, more like
> how many parallell connections you try to use in how short time period.
>
>
> At around 30000 number of threads, some of the requests started failing
>> with "Couldn't connect the server error" which I am assuming is happening
>> because my application is failing to find any more ports to bind to.
>>
>
> That seems reasonable, yes. strace would of course tell you exactly which
> syscall that fails.
>
>
> I decided to set the SO_REUSEADDR socket option in a hope to reuse the
>> sockets in the TIME_WAIT state. Following is a snippet of my code that I
>> wrote to set SO_REUSEADDR socket option:
>>
>
> ...
>
>
> But the behavior of my application is not changing.
>>
>
> I'm not an expert on SO_REUSEADDR, but perhaps that's too late to set that
> option?
>
> --
>
> / daniel.haxx.se
>
> -------------------------------------------------------------------
> 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-07