[snmp] SnmpContext question

Brian Jewell brian.jewell at modius.com
Wed Aug 22 12:07:04 BST 2007


Birgit,

A couple more questions regarding Contexts vs. Context Pools...

In an application that listens for SNMP traps, I'm trying to understand the
difference between instantiating individual Contexts (i.e., "new
SnmpContextv2c()") as opposed to using the Context Pool.

Does using the ListeningContextPool relieve me of the overhead of keeping
track of the contexts that are created? 

In other words, if I want to create a context to listen for traps, and later
I want to "turn off" trap listening by calling removeTrapListener(), does
using ListeningContextPool somehow associate the context that was created
with the instance of the class that created it?

Both approaches ("new SnmpContextv2c()" and "new ListeningContextPool()")
seemed to be used in the sample ReceiveTrap.java, so I'm a little confused
about which approach is best.

Thanks again for your help.

--Brian

-----Original Message-----
From: snmp-bounces at snmp.westhawk.co.uk
[mailto:snmp-bounces at snmp.westhawk.co.uk] On Behalf Of Birgit Arkesteijn
Sent: Wednesday, August 22, 2007 3:07 AM
To: List for discussion of the Westhawk SNMP stack
Subject: Re: [snmp] SnmpContext question

Hi Brian,


On 21/08/07 18:36, Brian Jewell wrote:
> Hi,
> 
> I'm having a little trouble understanding the use of SnmpContexts and
> SnmpContextPool's.
> 
> 1) When sending GET requests to the same host, is it correct to call "new
> SnmpContextPool()" to retrieve a context each time a PDU is to be sent?

That is correct.
See
uk.co.westhawk.examplev2c.set_one.createContext(..)


> 2) If an SnmpContext is created for receiving traps, and a trap listener
is
> added with 
> 
> 	SnmpContext context = new SnmpContext(.);
> 	context.addListener(.);
> 
> 
> When I wish to stop receiving traps from a specified host, do I need to
call
> removeTrapListener() using the *same* context (as I used for calling
> addListener(), or is it ok to create a *new* SnmpContext (with the same
> properties) and use it for calling removeTrapListener()?

You'll have to use the *same* context, since the listener is associated 
with that context (and that context only). *new* SnmpContext won't do 
the trick.


> 
> Thanks for your help.
> 
> --Brian

Cheers, Birgit


-- 
-- Birgit Arkesteijn, birgit at westhawk.co.uk,
-- Westhawk Ltd, Albion Wharf, 19 Albion Street, Manchester M1 5LN, UK
-- Company no: 1769350
-- Registered Office:
-- 15 London Road, Stockton Heath, Warrington WA4 6SJ. UK.
-- tel.: +44 (0)161 237 0660
-- <URL: http://www.westhawk.co.uk>
_______________________________________________
snmp mailing list
snmp at snmp.westhawk.co.uk
http://snmp.westhawk.co.uk/mailman/listinfo/snmp



More information about the snmp mailing list