I am using the following code to peform an SRV record lookup in an iPhone app, which utilises the callback (resolveCallback) to handle the result.
DNSServiceRef sdRef;
DNSServiceErrorType err;
err = DNSServiceQueryRecord(&sdRef,
0,
0,
[authorativeFQDN UTF8String],
kDNSServiceType_SRV,
kDNSServiceClass_IN,
resolveCallback,
NULL);
if(!err)
{
DNSServiceProcessResult(sdRef);
NSLog(@"Result: %@:%d", [NSString stringWithUTF8String:server], (NSInteger *)port);
}
DNSServiceRefDeallocate(sdRef);
The code is run within a threaded method. However, it appears that if no result is found from the lookup, the DNSServiceQueryRecord() blocks and the thread method never completes.
What is the correct way of performing this query and also capturing a failed response so that the thread completes and exits properly?