cURL / Mailing Lists / curl-library / Single Mail


Re: [Fwd: Patch for SO_BINDTODEVICE]

From: Ben Greear <>
Date: Thu, 12 Feb 2004 09:48:35 -0800

Daniel Stenberg wrote:
> On Thu, 12 Feb 2004, Ben Greear wrote:
>>>I experimented to bind to 'lo' and it failed to SO_BINDTODEVICE, but it
>>>could still continue and bind the good old fashioned way... In fact, it
>>>fails for eth0 as well on my linux 2.4.23 dev machine. Shouldn't it be
>>>possible to bind to the only network interface? Sorry for being so
>>>clueless about this.
>>Can you show me the error (errno?)
> Coming up. First, do note that the strlen() in the 5th argument to
> setsockopt() had a misplaced parenthesis, even in my posted edited version.
> Then, with that adjusted to strlen(data->set.device)+1 (as I figure we should
> include the trailing zero byte?)
> I get this:
> * SO_BINDTODEVICE failed, device eth0 errno 1, error: Operation not permitted
> I tried with and without that +1, and it makes no difference.
> If I use 'lo' I get:
> * SO_BINDTODEVICE failed, device lo errno 22, error: Invalid argument

I should definately fix the strlen problem. It very well may not
be possible to bind to loopback, but for eth0, it should work if
you are root. I'll test curl from the command line on my systems
today, but first I have to hack up apache to also do the BINDTODEVICE
so I can test the tricky scenarios.


Ben Greear <>
Candela Technologies Inc
Received on 2004-02-12