使用 iPhone SDK 查找 SRV 记录
在 Windows 或 Mac OS X 终端中,如果您键入...
nslookup -type=SRV _xmpp-server._tcp.gmail.com
...(例如),您将收到一堆与不同 google 聊天服务器相关的 SRV 记录。.
有没有人在这方面有任何经验,并且可能知道如何操作使用 iPhone SDK 提供此信息(主机名、端口、权重、优先级)? 我已经尝试过 Bonjour 课程,但到目前为止还没有运气..
谢谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信您需要使用 DNSServiceDiscovery 框架。 我没有 iPhone SDK,但 Google 搜索表明它可以在 iPhone 上使用。
请参阅 Apple 开发者网站,了解完整 API 详细信息。
我也包含了一些(不完整的)示例代码:
您需要提供自己的回调函数,并注意发送到回调的
rdata
字段采用有线格式,因此您将必须自己解码 SRV 记录字段中的原始数据。I believe you need to use the DNSServiceDiscovery framework. I don't have the iPhone SDK, but a Google search suggests that it is available on the iPhone.
See the Apple Developer Site for full API details.
I've included some (incomplete) sample code too:
You'll need to provide your own callback function, and note that the
rdata
field sent to the callback is in wire-format, so you'll have to decode the raw data from the SRV record fields yourself.我认为最好的选择是使用 CFNetwork 实现 DNS 查询工具。
尝试在此处阅读有关此内容的更多信息: http://developer.apple.com/documentation/Networking/Conceptual/CFNetwork/Introduction/chapter_1_section_1.html#//apple_ref/doc/uid/TP30001132-CH1-DontLinkElementID_24
I think your best bet is to implement a DNS query tool using CFNetwork.
Try to read more about this here: http://developer.apple.com/documentation/Networking/Conceptual/CFNetwork/Introduction/chapter_1_section_1.html#//apple_ref/doc/uid/TP30001132-CH1-DontLinkElementID_24
嗯,看起来我无法在模拟器或设备上运行
system()
。 我可以在模拟器上运行NSTask
,但不能在 iPhone 上运行,并且NSTask
不是Foundation
框架的一部分。ISC BIND 软件包具有 BSD 许可证。 如果可行的话,也许可以将
dig
代码的相关部分直接包装到项目中。Hmm, looks like I can't run
system()
on the Simulator or the device. I can runNSTask
on the Simulator, but not the iPhone, andNSTask
is not part of theFoundation
framework.The ISC BIND package has a BSD license. If feasible, perhaps relevant parts of the
dig
code could be wrapped into the project directly.