ListeningContext
and
ListeningContextPool
public class DefaultTrapContext extends ListeningContext
addTrapListener()
method,
the unhandled trap listeners are added via the
addUnhandledTrapListener()
.
Use one of the getInstance()
methods to get the instance and add a trap
listener. This class will fire undecoded trap events, i.e. the raw
data is sent and no attempt is made to decode the data into a pdu.
The SnmpContext classes provide functionality for decoded trap events. These classes will register themselves to the DefaultTrapContext object and only pass the event on if it matches their configuration.
Note that because only one instance of this class
can exist, the first call of getInstance()
will define
the settings
(i.e. port number and socket type) for the lifetime of the stack. All
the subsequent calls of getInstance()
will return the existing
instance, irrespective of the arguments.
On UNIX and Linux operating systems the default port where trap are sent (i.e. 162) can only be opened as root.
Note, this class is now deprecated. We are (very) slowly trying to move to a more general way of receiving packets and adding agent functionality. ListeningContext and ListeningContextPool allow the stack to listen to more than one port.
AbstractSnmpContext.addTrapListener(uk.co.westhawk.snmp.event.TrapListener)
,
ListeningContext
,
ListeningContextPool
bindAddr, hostPort, maxRecvSize, typeSocket
DEFAULT_TRAP_PORT
Modifier | Constructor and Description |
---|---|
protected |
DefaultTrapContext(int port)
Deprecated.
Constructor.
|
protected |
DefaultTrapContext(int port,
java.lang.String typeSocketA)
Deprecated.
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static DefaultTrapContext |
getInstance(int port)
Deprecated.
Returns the instance of DefaultTrapContext.
|
static DefaultTrapContext |
getInstance(int port,
java.lang.String typeSocketA)
Deprecated.
Returns the instance of DefaultTrapContext.
|
addRawPduListener, addUnhandledRawPduListener, destroy, getBindAddress, getHashKey, getMaxRecvSize, getPort, getTypeSocket, processIncomingMessage, removeRawPduListener, removeUnhandledRawPduListener, run, setMaxRecvSize, toString
protected DefaultTrapContext(int port) throws java.io.IOException
port
- The local port where traps are receivedjava.io.IOException
SnmpContextBasisFace.STANDARD_SOCKET
protected DefaultTrapContext(int port, java.lang.String typeSocketA) throws java.io.IOException
port
- The local port where traps are receivedtypeSocketA
- The type of socket to use.java.io.IOException
SnmpContextBasisFace.STANDARD_SOCKET
,
SnmpContextBasisFace.TCP_SOCKET
public static DefaultTrapContext getInstance(int port) throws java.io.IOException
java.io.IOException
public static DefaultTrapContext getInstance(int port, java.lang.String typeSocketA) throws java.io.IOException
java.io.IOException