snmp
Class SNMPv1TrapListenerInterface

java.lang.Object
  extended bysnmp.SNMPv1TrapListenerInterface
All Implemented Interfaces:
java.lang.Runnable

public class SNMPv1TrapListenerInterface
extends java.lang.Object
implements java.lang.Runnable

The class SNMPv1TrapListenerInterface implements a server which listens for trap messages sent from remote SNMP entities. The approach is that from version 1 of SNMP, using no encryption of data. Communication occurs via UDP, using port 162, the standard SNMP trap port. Applications utilize this class with classes which implement the SNMPTrapListener interface. These must provide a processTrap() method, and are registered/deregistered with this class through its addTrapListener() and removeTrapListener methods.


Field Summary
static int MAXSIZE
           
static int SNMP_TRAP_PORT
           
 
Constructor Summary
SNMPv1TrapListenerInterface()
          Construct a new trap receiver object to receive traps from remote SNMP hosts.
 
Method Summary
 void addTrapListener(SNMPTrapListener listener)
           
 void removeTrapListener(SNMPTrapListener listener)
           
 void run()
          The run() method for the trap interface's listener.
 void startReceiving()
          Start listening for trap messages.
 void stopReceiving()
          Stop listening for trap messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SNMP_TRAP_PORT

public static final int SNMP_TRAP_PORT
See Also:
Constant Field Values

MAXSIZE

public static final int MAXSIZE
See Also:
Constant Field Values
Constructor Detail

SNMPv1TrapListenerInterface

public SNMPv1TrapListenerInterface()
                            throws java.net.SocketException
Construct a new trap receiver object to receive traps from remote SNMP hosts. This version will accept messages from all hosts using any community name.

Method Detail

addTrapListener

public void addTrapListener(SNMPTrapListener listener)

removeTrapListener

public void removeTrapListener(SNMPTrapListener listener)

startReceiving

public void startReceiving()
Start listening for trap messages.


stopReceiving

public void stopReceiving()
                   throws java.net.SocketException
Stop listening for trap messages.

Throws:
java.net.SocketException

run

public void run()
The run() method for the trap interface's listener. Just waits for trap messages to come in on port 162 (or the port supplied in the constructor), then dispatches the retrieved SNMPTrapPDU to each of the registered SNMPTrapListeners by calling their processTrap() methods.

Specified by:
run in interface java.lang.Runnable
See Also:
Thread.run()