如何在 iOS 4 中列出 TCP/UDP 连接

2023-10-05移动开发问题
3

本文介绍了如何在 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 手册页)和 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 连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

恢复游戏 cocos2d
Resume game cocos2d(恢复游戏 cocos2d)...
2024-08-12 移动开发问题
6

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

[ios.cocos2d+box2d]如何禁用自动旋转?
[ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)...
2024-08-12 移动开发问题
7

从 Documents 目录存储和读取文件 iOS 5
Storing and reading files from Documents directory iOS 5(从 Documents 目录存储和读取文件 iOS 5)...
2024-08-12 移动开发问题
9

如何在 cocos2d 环境之外实现 cocos2d 游戏的虚拟摇杆?
How can I implement a virtual joystick for a cocos2d game outside the cocos2d environment?(如何在 cocos2d 环境之外实现 cocos2d 游戏的虚拟摇杆?)...
2024-08-12 移动开发问题
13