简体   繁体   中英

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 system 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM