> Assuming context of:  Modern unix-or-unix-like-system.
> 
> There is no portable way to force the network stack to prefer a given
> interface at the client-application level.  A call to connect(3) in
> the library will select the near endpoint based on the destination
> IP-addr. 
> 

Mea culpa ... A few minutes of experimentation allowed me to prove
myself wrong.   

Even client code can call bind() to prefer a source endpoint...

search through perlipc for the trivial TCP client and add the
following line:

bind(SOCK, sockaddr_in((0, inet_aton('192.234.345.456')))
    || die "bind: $!";

between the calls to socket() and connect().

Obviously you'll need to replace that bogus IP-addr with the ip-addr
of your local interface.

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
        Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to