Objective-C - 以编程方式确定 iPod touch 的 IP 地址
我正在为几个 iPod 设备使用 Objective-C 进行编程,并且我想知道一些事情。 我正在开发一个利用服务器-客户端模型的应用程序,并且使用带有 C 套接字的 UDP 协议。 是否有一个类可以让我确定 iPod 设备的 IP 地址? 在谷歌搜索其他论坛后,我没有找到任何东西。 显然这个命令不起作用,但像 ipAddress = self.ip 这样的命令正是我的想法。 我正在设置多播 C 套接字,并且正在尝试做一种类似于 ping 命令的解决方法,这显然在 Objective-C 中不存在,或者据我所知(这是有限的,因为我只进行过编程)至少从今年夏天开始就在 Objective-C 中)。 有什么建议或技巧吗?
I'm programming in objective-C for several iPod devices and I was wondering about something. I'm developing an application that utilizes the server-client model and I'm using the UDP protocol with C sockets. Is there a class out there that allows me to determine the iPod devices IP address? After googling around other forums, I haven't found anything. Obviously this command wouldn't work, but something like ipAddress = self.ip is what I had in mind. I'm setting up multicast C sockets and I'm trying to do a workaround that resembles the ping command, which obviously doesn't exist in objective-C either or to my knowledge (which is limited, as I've only been programming in objective-C since the start of this summer) at least. Any advice or tips?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这段代码将通过循环接口来检索它。
This snippet of code will retrieve it by looping through the interfaces.
你看到这个了吗? http://www.appsamuck.com/day4.html。 我认为正确的答案是在SDK中使用
CFHost
。编辑
该项目中的源代码似乎使用了以下代码,这使其成为完全无效的解决方案,除非 Apple 决定将
NSHost
放入 SDK 中。Did you see this? http://www.appsamuck.com/day4.html. I think the right answer is to use
CFHost
in the SDK.EDIT
It appears the source in that project is using the following code, which makes it a completely invalid solution unless Apple decides to put
NSHost
into the SDK.