Search code examples
iosdnssrv

iOS : DNS SRV lookup using DNSServiceQueryRecord


I plan to use apple's DNSServiceQueryRecord to resolve SRV records. I see that the callback passed to this method is called once per record that is returned from SRV lookup. How do i know that the query has completed and all the records have been returned?

Apple's documentation for your reference.

https://developer.apple.com/library/mac/documentation/Networking/Reference/DNSServiceDiscovery_CRef/index.html#//apple_ref/c/func/DNSServiceQueryRecord


Solution

  • I would like to point out the method "DNSServiceProcessResult" to process the DNS result is blocking. I used select() to look if there is data received in the socket to call DNSServiceProcessResult. This makes the method unblocking. I check if there is data in socket for 2 seconds and if i don't get back any results, I cancel the query.