我有兴趣获取 iOS 4.3 设备上的活动 TCP/UDP 网络连接列表.基本上,我正在寻找与在 OS X Darwin 下发出netstat -anp tcp"(或相同,但使用 udp)命令获得的相同类型的信息.
I am interested in deriving a list of active TCP/UDP network connections on an iOS 4.3 device. Basically, I'm looking for the same type of information one gets from issuing a "netstat -anp tcp" (or the same, but with udp) command under OS X Darwin.
我搜索了 Apple 的 iOS 开发人员库(尤其是 NSNetServices、CFNetServices 和 iOS 手册页)和 Internet,但没有得到好的结果.然而,有一个 iOS Netstat 应用程序(参见 http://itunes.apple.com/us/app/netstat/id400071873?mt=8&ign-mpt=uo%3D2),所以它看起来是可能的.
I've searched Apple's iOS Developer Library (especially NSNetServices, CFNetServices, and the iOS Manual Pages) and the Internet, but with no good results. Yet, there is an iOS Netstat app (see http://itunes.apple.com/us/app/netstat/id400071873?mt=8&ign-mpt=uo%3D2) out there, so it appears possible.
提前感谢您提供任何有用的指示/建议/想法.
Thanks in advance for any useful pointers/suggestions/thoughts.
我相信我现在已经回答了我自己的问题.以为我已经仔细研究了 sysctl() 库函数,但我没有!例如,以下将产生有关当前 TCP 连接的信息:
I believe I have now answered my own question. Thought I had taken a close enough look at the sysctl() library function, but I hadn't! For example, the following will yield information about the current TCP connections:
sysctlbyname("net.inet.tcp.pcblist", ...)
要获取有关 UDP 连接的信息,只需使用不同的管理信息库 (MIB) 名称:net.inet.udp.pcblist.
To get information about UDP connection, simply use a different Management Information Base (MIB) name: net.inet.udp.pcblist.
为方便起见,以下是相应 iOS 手册页的链接:
For convenience, here's a link to the appropriate iOS man page:
http://developer.apple.com/library/ios/#documentation/System/Conceptual/ManPages_iPhoneOS/man3/sysctlbyname.3.html
这篇关于如何在 iOS 4 中列出 TCP/UDP 连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!