Hamza Yerlikaya
Hamza Yerlikaya

Reputation: 49339

Java SOCKS proxy

Does the socksProxyHost property require an IP address?

System.setProperty("socksProxyHost", preferences.getProxyHost() );

Setting it like above, if I provide 127.0.0.1, I get connected to the proxy on my localhost. But if I provide localhost, it does not connect it. I have no other machines on the LAN I can use to this. So does anyone know if it works with hosts names or do I have to resolve the host and pass in an IP?

Upvotes: 3

Views: 3285

Answers (1)

Tom Hawtin - tackline
Tom Hawtin - tackline

Reputation: 147164

System properties are just a dumb map. There are no observers to be notified when a value changes. It is normal to read a value just once and store it in a private static final, rather than looking the value up every time that it is needed.

Probably the relevant code is initialised whilst loading your application, so the value has already been read. A quick look at the API docs shows a promising method to call to change the default proxy: ProxySelector.setDefault.

Upvotes: 2

Related Questions