You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Erik Erskine <er...@sundayta.com> on 2003/05/13 13:10:48 UTC

[HttpClient] Binding to a particular interface/IP?

Hello,

Is it possible to force HttpClient to bind to a particular IP on the 
client machine?  I'm using a machine with multiple IP's (on the same 
network) and need to control which one of them is used to connect to a 
remote server.

thanks,

Erik

/--------------------------------------------------------------------\
|   Erik Erskine                                                     |
|   Sundayta Ltd                                                     |
\--------------------------------------------------------------------/


Re: [HttpClient] Binding to a particular interface/IP?

Posted by Erik Erskine <er...@sundayta.com>.
Richard,

 > In that case, I just found this while browsing the CVS. Looks like
 > the feature you are looking for just got implemented.

Great!  I've tried again using CVS - this does exactly what I need.

Thanks for your help,

Erik

/--------------------------------------------------------------------\
|   Erik Erskine                                                     |
|   Sundayta Ltd                                                     |
\--------------------------------------------------------------------/


Re: [HttpClient] Binding to a particular interface/IP?

Posted by Richard Becke <ri...@disputable.org>.
In that case, I just found this while browsing the CVS. Looks like
the feature you are looking for just got implemented.


HostConfiguration.java, Revision 1.11

Added support for setting HttpConnection local address.
PR: 19827
Submitted by: Laura Werner

     /**
+     * Set the local address to be used when creating connections.
+     * If this is unset, the default address will be used.
+     * This is useful for specifying the interface to use on multi-homed
or clustered systems.
+     *
+     * @param localAddress the local address to use
+     */
+    public synchronized void setLocalAddress(InetAddress localAddress) {
+        this.localAddress = localAddress;
+    }

-- 
/* ®ß */

<quote who="Erik Erskine">
> Richard,
>
>  > This is, I think, not possible. A client does not "bind" to an IP or
> interface. The IP routing subsystem of the OS makes that decision
> based upon target IP address and the routing tables.
>
> This is not a routing issue - the two interfaces are on the same
> network.  They are actually the same card using IP aliasing to have two
> addresses.
>
> What I'm looking for is an equivalent of the following method in
> java.net.Socket:
>
> public Socket(InetAddress address,
>                int port,
>                InetAddress localAddr,
>                int localPort)
>
> The remote server will only accept requests from one of the addresses.
>
> Erik
>
> /--------------------------------------------------------------------\ |
>   Erik Erskine                                                     | |
> Sundayta Ltd                                                     |
> \--------------------------------------------------------------------/
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For
> additional commands, e-mail: commons-user-help@jakarta.apache.org




Re: [HttpClient] Binding to a particular interface/IP?

Posted by Erik Erskine <er...@sundayta.com>.
Richard,

 > This is, I think, not possible. A client does not "bind" to an IP or
 > interface. The IP routing subsystem of the OS makes that decision
 > based upon target IP address and the routing tables.

This is not a routing issue - the two interfaces are on the same 
network.  They are actually the same card using IP aliasing to have two 
addresses.

What I'm looking for is an equivalent of the following method in 
java.net.Socket:

public Socket(InetAddress address,
               int port,
               InetAddress localAddr,
               int localPort)

The remote server will only accept requests from one of the addresses.

Erik

/--------------------------------------------------------------------\
|   Erik Erskine                                                     |
|   Sundayta Ltd                                                     |
\--------------------------------------------------------------------/


Re: [HttpClient] Binding to a particular interface/IP?

Posted by Richard Becke <ri...@disputable.org>.
This is, I think, not possible. A client does not "bind" to an IP or
interface. The IP routing subsystem of the OS makes that decision based
upon target IP address and the routing tables.

-- 
/* ®ß */

<quote who="Erik Erskine">
> Hello,
>
> Is it possible to force HttpClient to bind to a particular IP on the
> client machine?  I'm using a machine with multiple IP's (on the same
> network) and need to control which one of them is used to connect to a
> remote server.
>
> thanks,
>
> Erik
>
> /--------------------------------------------------------------------\ |
>   Erik Erskine                                                     | |
> Sundayta Ltd                                                     |
> \--------------------------------------------------------------------/
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For
> additional commands, e-mail: commons-user-help@jakarta.apache.org