[SNMP4J] Re: Help on SNMP Trap Receiver

vikram shetty vikramganiga at gmail.com
Mon Oct 20 12:18:47 CEST 2008


Hi Frank,

  in DefaultUdpTransportMapping class

     /**
   * Starts the listener thread that accepts incoming messages. The thread
is
   * started in daemon mode and thus it will not block application
terminated.
   * Nevertheless, the {@link <%7B at link> #close()} method should be called
to stop the
   * listen thread gracefully and free associated ressources.
   *
   * @throws IOException
   */
  public synchronized void listen() throws IOException {
    if (listener != null) {
      throw new SocketException("Port already listening");
    }
    if (socket == null) {
      socket = new DatagramSocket(udpAddress.getPort());
    }
    listenerThread = new ListenThread();
    listener = SNMP4JSettings.getThreadFactory().createWorkerThread(
        "DefaultUDPTransportMapping_"+getAddress(), listenerThread, true);
    listener.run();
  }
 listener is daemon process  and because daemon process it is cause issues
while continuously listening  traps on udp port because how can in trap
application waits  for traps continuously where snmp.listen is continuously
listen port in background , if we put infinity loop in the  trap program it
casues cpu utilization. There are any otherways to achieve listening port
continuously like by creating listener not a  daemon process or i need to
build proper logic in trap application to listen port continuously.


Regards,
Vikram Shetty,
 +91-9819676198 .

On Fri, Oct 17, 2008 at 11:40 AM, vikram shetty <vikramganiga at gmail.com>wrote:

>  Hi ,
>
>     UdpAddress portid = new UdpAddress(162);
>     DefaultUdpTransportMapping transport = new
> DefaultUdpTransportMapping(portid);
>     Snmp snmp = new Snmp(transport);
>     snmp.listen()
>
>    In above part of the code , how  can we make snmp.listen() continuously
> listen a UDP port( here it is 162) or What is missing to listen a port
> continuously.
>
>    This is one of requirement of while implementing SNMP Trap Receiver by
> using SNMP4j API , because trap receiver need to be continuously listen a
> port and receive a traps or messages.
>
> Thanks,
> Vikram Shetty,
>  +91-9819676198
>
>
>



More information about the SNMP4J mailing list