使用 iPhone SDK 查找 SRV 记录

发布于 2024-07-08 19:08:29 字数 279 浏览 8 评论 0 原文

在 Windows 或 Mac OS X 终端中,如果您键入...

nslookup -type=SRV _xmpp-server._tcp.gmail.com

...(例如),您将收到一堆与不同 google 聊天服务器相关的 SRV 记录。.

有没有人在这方面有任何经验,并且可能知道如何操作使用 iPhone SDK 提供此信息(主机名、端口、权重、优先级)? 我已经尝试过 Bonjour 课程,但到目前为止还没有运气..

谢谢!

In either a Windows or Mac OS X terminal if you type...

nslookup -type=SRV _xmpp-server._tcp.gmail.com

... (for example) you will receive a bunch of SRV records relating to different google chat servers..

Does anyone have any experience in this area and possibly know how to service this information (hostname, port, weight, priority) using the iPhone SDK? I have experimented with the Bonjour classes, but as yet have had no luck..

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

空城仅有旧梦在 2024-07-15 19:08:29

我相信您需要使用 DNSServiceDiscovery 框架。 我没有 iPhone SDK,但 Google 搜索表明它可以在 iPhone 上使用。

请参阅 Apple 开发者网站,了解完整 API 详细信息

我也包含了一些(不完整的)示例代码:

#include <dns_sd.h>

int main(int argc, char *argv[])
{
   DNSServiceRef sdRef;
   DNSServiceErrorType res;

   DNSServiceQueryRecord(
     &sdRef, 0, 0,
     "_xmpp-server._tcp.gmail.com",
     kDNSServiceType_SRV,
     kDNSServiceClass_IN,
     callback,
     NULL
  );

  DNSServiceProcessResult(sdRef);
  DNSServiceRefDeallocate(sdRef);
}

您需要提供自己的回调函数,并注意发送到回调的 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:

#include <dns_sd.h>

int main(int argc, char *argv[])
{
   DNSServiceRef sdRef;
   DNSServiceErrorType res;

   DNSServiceQueryRecord(
     &sdRef, 0, 0,
     "_xmpp-server._tcp.gmail.com",
     kDNSServiceType_SRV,
     kDNSServiceClass_IN,
     callback,
     NULL
  );

  DNSServiceProcessResult(sdRef);
  DNSServiceRefDeallocate(sdRef);
}

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.

め可乐爱微笑 2024-07-15 19:08:29

我认为最好的选择是使用 CFNetwork 实现 DNS 查询工具。

尝试在此处阅读有关此内容的更多信息: http://developer.apple.com/documentation/Networking/Conceptual/CFNetwork/Introduction/chapter_1_section_1.html#//apple_ref/doc/uid/TP30001132-CH1-DontLinkElementID_24

琉璃梦幻 2024-07-15 19:08:29

嗯,看起来我无法在模拟器或设备上运行 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 run NSTask on the Simulator, but not the iPhone, and NSTask is not part of the Foundation 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文