Writing a java.net.SocketImplFactory

2020-07-07 04:55发布

问题:

The javadoc for SocketImplFactory specifically mentions that "An application, by changing the socket factory that creates the socket implementation, can configure itself to create sockets appropriate to the local firewall."

However, in order to connect to the firewall in question, one would need a real socket to do the real connection. With the default SocketImplFactory replaced, how does one go about getting a real socket?

I know that java.net.PlainSocketImpl and java.net.SocksSocketImpl are available on Sun's Java, but is there any way to do it in a way that is portable between JVMs?

回答1:

There is some information about the thinking behind this documentation here



回答2:

You create the socket to connect to the firewall before calling setSocketImplFactory.



标签: java sockets