- All Implemented Interfaces:
- java.net.SocketImplFactory
public class TimeoutSocketFactory
extends java.lang.Object
implements java.net.SocketImplFactory
This class provides an implementation of a Socket factory
that provides a timeout. Once installed, this
implementation will be used for all Socket. The timout
applies to the "connect" as well as "read" methods.
Socket timeouts are an ongoing problem since TCP stacks can take
a very long time (forever) to determine that the logical TCP
connection no longer exists. This implementation resolves this
problem by having a fixed and constant timeout for socket operations.
The operation of this object creates
an instance of the non-public class "java.net.SocksSocketImpl" and
accesses the non-public "timeout" field.
This class will fail to install if a security manager is present,
for example in an Applet. It may also fail in non-Sun JVM's.
If the installation of this class fails, the system will run with
the default SocketImplFactory for the JVM which means that the timeout
feature will be lost, but no other functionality.