cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [Fwd: Patch for SO_BINDTODEVICE]

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Thu, 12 Feb 2004 16:22:33 +0100 (CET)

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 had a hard time testing this so far, and mainly just wanted it take the
> code branch in gdb. That is most likely due to my program that uses
> libcurl. How did you test this?

curl --interface [interface] [URL]

> good trick with the #ifdef SO_BINDTODEVICE, I hadn't thought of that :)

:-) I found discussions about adding SO_BINDTODEVICE in other OSes too, while
googling, so I thought it would be a good start to be ready for that!

-- 
    Daniel Stenberg -- http://curl.haxx.se/ -- http://daniel.haxx.se/
   [[ Do not send mails to this email address. They won't reach me. ]]
Received on 2004-02-12