Skip to content

Instantly share code, notes, and snippets.

@yarshure
Created July 1, 2014 08:01
Show Gist options
  • Save yarshure/515b833fa1ec3605d12f to your computer and use it in GitHub Desktop.
Save yarshure/515b833fa1ec3605d12f to your computer and use it in GitHub Desktop.
iOS dns TXT record query
#include <dns_sd.h>
void DNSSD_API callback
(
DNSServiceRef sdRef,
DNSServiceFlags flags,
uint32_t interfaceIndex,
DNSServiceErrorType errorCode,
const char *fullname,
uint16_t rrtype,
uint16_t rrclass,
uint16_t rdlen,
const void *rdata,
uint32_t ttl,
void *context
);
void DNSSD_API callback
(
DNSServiceRef sdRef,
DNSServiceFlags flags,
uint32_t interfaceIndex,
DNSServiceErrorType errorCode,
const char *fullname,
uint16_t rrtype,
uint16_t rrclass,
uint16_t rdlen,
const void *rdata,
uint32_t ttl,
void *context
)
{
NSLog(@"queryCallback: flags == %d error code == %d", flags, errorCode);
NSLog(@"result %s",(char *)rdata);
}
int test()
{
DNSServiceRef sdRef;
DNSServiceErrorType res;
res=DNSServiceQueryRecord(
&sdRef, 0, 0,
"all",
kDNSServiceType_TXT,
kDNSServiceClass_IN,
callback,
NULL
);
DNSServiceProcessResult(sdRef);
DNSServiceRefDeallocate(sdRef);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment