curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: bind address lockup

From: Ray Satiro via curl-library <>
Date: Sun, 7 Jul 2019 00:13:56 -0400

On 6/27/2019 5:21 PM, Robert NEMKIN via curl-library wrote:
> Hope I'm right, but bind() is for server/receiving sockets.
> I want to bind to a specific interface as client socket.
> I use curl_easy_setopt(curl, CURLOPT_INTERFACE, interface) to bind to
> a specific interface. I guess, that I set up the options in libcurl,
> then when I issue curl_easy_perform(curl), it does all the work to set
> up the socket and do the transfer.
> > But your way of saying this makes me curious. Why do you call it
> > setsockopt bind address? Where exactly does it hang? And for how long?
> I know, that setsockopt is thread safe according to the POSIX
> standard. But is the linux kernel (4.19.37-5) implementation correct?
> Sometimes it took more than a minute to start the transfer, sometimes
> it never starts.
> >
> >> Maybe I can use some workaround? E.g. download a little testfile
> >> sequential to do the bindaddress serialized with keepalive, then start
> >> the multithreaded download?
> >
> > You could add one transfer at a time and only start the next once the
> > previous has started to get data as then you know they don't do bind()
> > at the same time. But I wouldn't feel entirely safe with that since
> then
> > we don't know for sure where the problem is or that this is actually a
> > working fix or just accidentally working...
> >
> I guess it's a kernel problem, because if I start four wget from
> commandline, it locks too.
> Example:
> wget --bind-address=x.y.z.p -O /dev/null -q
> http://server1.domain/testfile &?? wget --bind-address=x.y.z.p -O
> /dev/null -q http://server2.domain/testfile & wget
> --bind-address=x.y.z.p -O /dev/null -q http://server3.domain/testfile
> & wget --bind-address=x.y.z.p -O /dev/null -q
> http://server4.domain/testfile &
> I need a fix in short term. If I'm right and the kernel implementation
> has a bug, it would took more time to resolve it.
> To transfer two files per connectin is my newest idea, I don't know if
> it's working or not.
> My guess is that the kernel is fast enough to do the setsockopt in
> case of 1-2 ethernet cards, so the bug remains hidden. Maybe I'm the
> first who installed 18 cards in one machine, and tested it for this usage.

If you file as a linux bug please let us know where it's filed. Thanks

Received on 2019-07-07