cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: SO_REUSEADDR and libcurl

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sat, 28 Jun 2014 04:54:06 +0200 (CEST)

On Fri, 27 Jun 2014, Sachin Nikumbh wrote:

> Is there any way to set the SO_REUSEADDR socket option through the libcurl
> API? My client application is spawning many threads which are opening new
> connections with an application server. But soon the application fails due
> to lack of available ports as most of them are in the TIME_WAIT state.

Why do they end up in TIME_WAIT ?

> Based on some old threads found over the net, it was not possible at some
> point.

What wasn't possible? Also, be careful about trusting specific information
"found over the net" if it is about libcurl details and doesn't come from this
mailing list or our documentation.

> I was wondering of there is any undocumented way of passing SO_REUSEADDR
> option.

Several. CURLOPT_SOCKOPTFUNCTION and CURLOPT_OPENSOCKETFUNCTION are two
obvious ways you can do it with. But I would also persue the reason for this
situation in the first place and make sure there's nothing wrong that causes
it to trigger as then doing socket options would only hide the symptom and not
fix the real problem - if even that.

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