Created
July 1, 2014 08:01
-
-
Save yarshure/515b833fa1ec3605d12f to your computer and use it in GitHub Desktop.
iOS dns TXT record query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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