简体   繁体   English

使用C#创建SNMP侦听器(服务器)

[英]Create SNMP Listener (server) using C#

I know it's possible to create an agent and query an SNMP enabled device but i need to create an 2 or more SNMP listener in one PC on different ports so that one PC can have may SNMP listener. 我知道可以创建代理并查询启用SNMP的设备,但是我需要在一台PC上的不同端口上创建2个或更多SNMP侦听器,以便一台PC可以具有SNMP侦听器。 So that i can send my own message when an agnent queries. 这样,当查询异常时我就可以发送自己的消息。 Wel as for my understanding SNMP uses UDP so listening UDP sockets on different ports can i receive requests ? 就我的理解而言,SNMP使用UDP很方便,因此我可以在不同端口上侦听UDP套接字吗? Or are there any restrictions? 还是有任何限制?

If you scan the documentation of #SNMP carefully, you should note that under Lextm.SharpSnmpLib.Messaging namespace, there is a class called ListenerBinding , 如果仔细阅读#SNMP的文档,应注意在Lextm.SharpSnmpLib.Messaging命名空间下,有一个名为ListenerBinding的类,

http://help.sharpsnmp.com/html/N_Lextm_SharpSnmpLib_Messaging.htm http://help.sharpsnmp.com/html/N_Lextm_SharpSnmpLib_Messaging.htm

Thus, for a single Listener instance, you can add multiple bindings, each mapping to an individual port as you wished. 因此,对于单个Listener实例,您可以添加多个绑定,每个绑定都可以根据需要映射到单个端口。 That's the quickest way to monitor multiple ports with a single Listener . 这是用单个Listener监视多个端口的最快方法。

Of course, you can create multiple Listener instances or even multiple processes. 当然,您可以创建多个Listener实例,甚至可以创建多个进程。 Technically you get all the freedom. 从技术上讲,您获得了所有的自由。 SNMP protocol does not restrict on which port should be used, though 161 is the default port number. SNMP协议不限制应使用哪个端口,尽管默认端口号为161。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM