I believe that you need to use the DNSServiceDiscovery framework. I do not have an iPhone SDK, but a Google search suggests that it is available on the iPhone.
See Apple Developer Website for full API details .
I have included some (incomplete) sample code:
#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 will need to provide your own callback function and note that the rdata field sent to the callback is in a wired format, so you will have to decode the raw data from the SRV record fields yourself.
source share