Windows Forms Agent Code Example
The following example demonstrates an SNMP agent in a Windows Forms environment. The agent receives requests and responds.
< Back to all samples for PowerSNMP for .NET
private void button1_Click(object sender, EventArgs e)
//This application has a User-Interface, which we do not want to block.
//A callback function is passed to Start, which launches an internal worker thread
//that listens for requests.
//This simple example supports just one variable, which is added to the agent's
string iid = agent1.Mib.GetByNodeName(NodeName.sysContact).Iid;
agent1.Variables.Add(iid, agent1.Mib.CreateVariable(NodeName.sysContact, "Ned Stark"));
//Start listening for requests.
private void agent1_MessageReceived(Agent agent, RequestMessage request, object state)
//This callback function executes whenever the agent receives a request.
//A Response message is created and sent to the querying manager.