[SNMP4J] How can I get trap?

hblq112 hblq112 at 163.com
Sun Feb 25 10:49:56 CET 2007


           i want to get trap from my computer, but there was noting recevied. why? follow is
the  codes.
           if   i   want to  Listen traps  always    what will  i   do    for   my   code.
          
 thanks!
********************************************************* 
try
 {
       UdpAddress address = new UdpAddress("127.0.0.1/162");
      TransportMapping transport = new DefaultUdpTransportMapping(address);
       Snmp snmp = new Snmp(transport);
       CommandResponder trapPrinter = new CommandResponder() {
                public synchronized void processPdu(CommandResponderEvent e)
               {
                      PDU command = e.getPDU();
                     if (command != null)
                      {
                           System.out.println(command.toString());
                     }
                     else
                    {
                           System.out.println("No Trap!");
                    }
             }
         };
   snmp.addCommandResponder(trapPrinter);
   transport.listen();

  }catch(Exception ex)
  {
   ex.printStackTrace();
  }


More information about the SNMP4J mailing list