- java.lang.Object
-
- java.util.TimerTask
-
- org.snmp4j.transport.SocketTimeout<A>
-
- All Implemented Interfaces:
java.lang.Runnable
public class SocketTimeout<A extends Address> extends java.util.TimerTask
TheSocketTimeout
is aTimerTask
that provides means to detect when a socket is not used for predefined time and then close the socket and free its resources.- Since:
- 3.0
-
-
Field Summary
Fields Modifier and Type Field Description private AbstractServerSocket<A>
entry
private static LogAdapter
logger
private ConnectionOrientedTransportMapping<A>
transportMapping
-
Constructor Summary
Constructors Constructor Description SocketTimeout(ConnectionOrientedTransportMapping<A> transportMapping, AbstractServerSocket<A> entry)
Create a socket timeout handler for the providedTransportMapping
and server socket entry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cancel()
void
run()
Runs a timeout check and if the socket has timed out, it removes the socket from the associatedTransportMapping
.
-
-
-
Field Detail
-
logger
private static final LogAdapter logger
-
transportMapping
private ConnectionOrientedTransportMapping<A extends Address> transportMapping
-
entry
private AbstractServerSocket<A extends Address> entry
-
-
Constructor Detail
-
SocketTimeout
public SocketTimeout(ConnectionOrientedTransportMapping<A> transportMapping, AbstractServerSocket<A> entry)
Create a socket timeout handler for the providedTransportMapping
and server socket entry.- Parameters:
transportMapping
- aConnectionOrientedTransportMapping
that acts as a server.entry
- aAbstractSocketEntry
representing a server socket for a client connection associated with the above transport mapping.
-
-
Method Detail
-
run
public void run()
Runs a timeout check and if the socket has timed out, it removes the socket from the associatedTransportMapping
.- Specified by:
run
in interfacejava.lang.Runnable
- Specified by:
run
in classjava.util.TimerTask
-
cancel
public boolean cancel()
- Overrides:
cancel
in classjava.util.TimerTask
-
-