SNMP SubTree

  • Thread starter Thread starter Dan Pavel
  • Start date Start date
D

Dan Pavel

Hi,

I have a function, mib_read_getnext, where I get a MIB subtree. It works
well but randomly hangs. I am using snmp.dll from
http://www.c-sharpcorner.com/Code/2002/Sept/SnmpLib.asp

How I can check that when I create a new ms is hanged or not and if it
is hanged, bypass it and assign val="0";

I am kind of new in programming, so if you can, give me a detailed
answer with code.

Thanks in advance.

---- My code----

private string mib_read_getnext(string host, uint[] mib)
{
lock(this)
{
string val="";
try
{
ManagerSession sess = new ManagerSession(host,"public");
ManagerSubTree ms = new ManagerSubTree(sess,mib);
//---^--- Above is the Crash !!!
if (ms.Length==0)
{
val="0";// SubTree is empty
}
else
foreach(ManagerItem mi in ms)
{
val=mi.Value.ToString();
}
}
catch (Exception e)
{
val="NULL";
}
return val;
 
I found that the crash happends when the code make ms = new
ManagerSubTree(sess,mib), and this is happening in snmp.dll, so I cannot
change it. My problem is how can I bypass the ms = new
ManagerSubTree(sess,mib) if I can't get a value in 100 milliseconds. I
am new in programming and if you can, give me a detailed solution
(little code).
 
Back
Top