Question:
What is the SocketImpl class used for?
Answer:
SocketImpl is an abstract class that provides an interface for customizing socket implementations. Subclasses of SocketImpl are not intended to be explicitly instantiated. Instead, they are created by a SocketImplFactory. The motivation for this design is to allow you to change the default type of socket used by an entire application by calling Socket.setSocketImplFactory(), making it unnecessary to rewrite all of your networking code. Custom sockets are necessary for features such as SSL and firewall tunneling. Unfortunately, the global nature of setSocketImplFactory() is rather limiting, as it doesn’t allow you to use multiple types of sockets within a single application. You can get around this by subclassing Socket and using the protected Socket(SocketImpl) constructor that was introduced in JDK 1.1.