Subject: Re: [PATCH] Bind to device

Re: [PATCH] Bind to device

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 24 Mar 2009 13:52:05 +0100 (CET)

On Tue, 24 Mar 2009, Richard Strand wrote:

> I have created a patch for c-ares 1.6.0 which allows you to force c-ares to
> bind to a specific device for the DNS request.
>
> I suspect this will only work in Linux at the moment and will probably break
> other builds.

Right, SO_BINDTODEVICE is Linux-specific so you should rather make all this
code within #ifdef SO_BINDTODEVICE. And you'll also need super-user rights on
most machines to be allowed to use this so it'll also not work for many apps
even on Linux.

> I'd really appreciate some feedback on this. Does anyone else want this, and
> how can it be made to work cross platform?

By using "normal" bind!

For inspiration, see the bindlocal() function in libcurl's connect.c file:

http://cool.haxx.se/cvs.cgi/curl/lib/connect.c?rev=1.213&content-type=text/vnd.viewcvs-markup

-- 
  / daniel.haxx.se
Received on 2009-03-24