如何列出iOS 4中的TCP / UDP连接 [英] How to List TCP/UDP Connections in iOS 4

查看:101
本文介绍了如何列出iOS 4中的TCP / UDP连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我感兴趣的是在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手册页)和互联网,但没有取得好成绩。然而,有一个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连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆