开发者

How to make the JVM use a given source IP by default?

Is there any way to force the JVM to use a specific source IP address when using the default, built-in java.xml.SOAPConnectionFactory? It appears the default ends up creating HttpSOAPConnection objects (sun p开发者_开发知识库rivate API), which then uses HttpURLConnection underneath the hood. I can't seem to find any system property to make HttpURLConnection use a specific source IP. There is a similar stackoverflow question, but I'm hoping someone else has more information, or a trick I can use.


Http Client from Apache Commons (http://hc.apache.org/httpcomponents-client-ga/) supports this:

"ConnRoutePNames.LOCAL_ADDRESS='http.route.local-address': defines a local address to be used by all default route planner. On machines with multiple network interfaces, this parameter can be used to select the network interface from which the connection originates. This parameter expects a value of type java.net.InetAddress. If this parameter is not set, a default local address will be used automatically."

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜