How to use URLConnection through a SOCKS proxy?
How can I set the SOCKS
proxy for a URLConnection
given by (new URL(url)).openConnection()
?
Different proxies are needed on a per-connection basis, so please don't suggest setting sys开发者_如何学Gotem properties.
If you want to use different proxy settings on a per-connection bases, you can use the Java 6.0 ProxySelector
mechanism as described in Java Networking and Proxies. Specifically, read sections 3 and 4.
精彩评论