在用 Swift 编写的应用程序中使用 SNMP++ 库 [英] Using SNMP++ library in application written in Swift
问题描述
我是 Swift 新手,如果有人能告诉我如何在一个简单的 iOS 应用程序中使用 SNMP++ lib(用 C++ 编写)迅捷?如何导入lib并开始编码?谢谢.
I'm new in Swift and I would like if someone could tell me how can I use SNMP++ lib (written in C++) in a simple iOS application written in Swift? how to import the lib and begin coding? Thank You.
推荐答案
2016 年,Dariusz Stojaczyk 编写了 C 代码来构建探针并解构隐藏在 一个专注于 BER 的项目.该项目包含获取一个或多个 SNMP OID 并构建完整 SNMP 消息所需的代码,然后获取响应并对其进行解码,但没有实际执行此操作的网络代码.
In 2016, Dariusz Stojaczyk wrote C code to construct probes and deconstruct response of SNMP v1 messages hidden in a project focused on BER. That project contains the code necessary to take one or more SNMP OIDs and construct a full SNMP message, then take a response and decode it, but has no networking code to actually do this.
我使用了这段代码,并且添加了一个 ObjectiveC 包装器,可用于使用现有代码构造一条 SNMPv1 消息,使用 Socket 将其发送到端点,并使用调度块接收具有用户可设置超时的响应.
I took this code and added an ObjectiveC wrapper that can be used to use the existing code to construct a SNMPv1 message, send it to an endpoint using a Socket, and receive a response with a user settable timeout using a dispatch block.
这段代码比任何提供步行、v2/v3 和陷阱等附加服务的大型库都要简单得多.如果您只想读取一个或多个 OID,那么您应该欣赏这段代码.
This code is far simpler than any of the big libraries that offer additional services like walking, v2/v3, and traps. If all you want to do is read one or more OIDs, then you should appreciate this code.
这篇关于在用 Swift 编写的应用程序中使用 SNMP++ 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!