tags:

views:

437

answers:

1
+1  Q: 

Java SOCKS proxy

Does socksProxyHost property requires an IP address

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

setting it like following, If i provide 127.0.0.1 i get connected to the proxy on my localhost but giving it localhost it does not connect it. I have no other machine on lan to test it so does anyone know if it works with hosts names or do i have to resolve host and pass it an IP?

A: 

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.

Tom Hawtin - tackline