Creates an unconnected socket, specifying the type of proxy, if any, that should be used regardless of any other settings.
If there is a security manager, its checkConnect method
is called with the proxy host address and port number
as its arguments. This could result in a SecurityException.
Examples:
Socket s = new Socket(Proxy.NO_PROXY); will create
a plain socket ignoring any other proxy configuration.Socket s = new Socket(new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("socks.mydom.com", 1080)));
will create a socket connecting through the specified SOCKS proxy
server.
proxy | a Proxy object specifying what kind
of proxying should be used. |
IllegalArgumentException | if the proxy is of an invalid type
or null. | |
SecurityException | if a security manager is present and permission to connect to the proxy is denied. |
java.net.ProxySelector, java.net.Proxy
Diagram: Socket