> Hi. I'm trying to specify the local address and port (i.e. network
> interface) to use for a URLConnection.
>
> I didn't see any public methods in the documentation for the
> java.net package that would allow me to do this.

Signature
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
> Normally the OS should be allowed to choose the appropriate outgoing
> interface based on information in the routing table
Normally, yes, but not for my sinister plans :)
> Why do you need to specify the local port?
I'm working on framework that will allow users to add attributes to
network interfaces, and users will be able to set acceptable levels on
these attributes that the framework will consult in order to select
which network interface to use as the primary interface.
I tried checking out what's involved in subclassing URLStreamHandler,
but it's abstract and I can't debug into it because the concrete class
is in sun.net.www.protocol.http. I'll give it another pass, tho, if
there's no easy way out.
Tks.
Gordon Beaton - 26 Feb 2007 10:14 GMT
>> Why do you need to specify the local port?
>
> I'm working on framework that will allow users to add attributes to
> network interfaces, and users will be able to set acceptable levels
> on these attributes that the framework will consult in order to
> select which network interface to use as the primary interface.
I understand why one might want to specify the local address or
outgoing interface, but in the subject line you write "and port",
which I can't see any need to specify at the client.
/gordon

Signature
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e