Class ListeningContext

java.lang.Object
uk.co.westhawk.snmp.stack.ListeningContext
All Implemented Interfaces:
Runnable, ListeningContextFace
Direct Known Subclasses:
DefaultTrapContext

public class ListeningContext extends Object implements ListeningContextFace, Runnable
The ListeningContext class will enable this stack to receive packets. This class replaces the deprecated DefaultTrapContext class. The context will only start receiving (or listen for) packets when there is at least one listener registered.

Two kind of listeners can be added; the normal and unhandled PDU listeners. The normal PDU listeners are added via the addRawPduListener() method, the unhandled PDU listeners are added via the addUnhandledRawPduListener(). Both these listeners provide undecoded events.

The SnmpContext classes provide functionality for decoded PDU and trap events. These classes will register themselves via the addRawPduListener() to the ListeningContext object and only pass the (decoded) event on if it matches their configuration.

On UNIX and Linux operating systems the default port where PDUs and traps are sent (i.e. 161 and 162) can only be opened as root.

Only one process can listen on a certain port. To prevent more than one ListeningContext listening on the same port, use the ListeningContextPool class.

Since:
4_14
Version:
$Revision: 3.12 $ $Date: 2009/03/05 13:24:00 $
Author:
Birgit Arkesteijn
See Also: