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 14:39:52 +0100 (CET)

On Wed, 11 Feb 2004, Ben Greear wrote:

> I have a patch here that should allow CURL to bind more tightly to an
> interface. It's use may be somewhat limited in scope, but it does fix a
> problem for me :)

Cool. I just have a few questions on this!

> + if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
> + data->set.device, strlen(data->set.device + 1)) != 0) {
> + /* printf("Failed to BINDTODEVICE, socket: %d device: %s error: %s\n",
> + sockfd, data->set.device, strerror(errno)); */
> + failf(data, "SO_BINDTODEVICE failed");

When this operation fails, what is the significance?

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.

I take it failf() should rather be infof() in this case?

BTW, attached to this mail is my modified patch that applies fine on the CVS
code.

-- 
    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