Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我打算使用苹果的 DNSServiceQueryRecord 来解析 SRV 记录。我看到每个从 SRV 查找返回的记录都会调用传递给此方法的回调一次。我怎么知道查询已经完成并且所有记录都已返回?
Apple 的文档供您参考。
https://developer.apple.com/library/mac/documentation/Networking/Reference/DNSServiceDiscovery_CRef/index.html#//apple_ref/c/func/DNSServiceQueryRecord
我想指出处理 DNS 结果的方法“DNSServiceProcessResult”是阻塞的。我使用 select() 来查看套接字中是否接收到数据以调用 DNSServiceProcessResult。这使得该方法畅通无阻。我检查套接字中是否有数据 2 秒,如果我没有得到任何结果,我取消查询。