我一直在寻找通过使用iOS SDK获得DNS记录的解决方案?
我能够通过主机名here解析ip地址,但这不是我想要的.我需要得到所有的DNS记录,包括PTR,Name,NS,MX,CNAMEE 210等等。非常感谢您的帮助或代码片段。
发布于 2012-03-02 06:19:26
试探性
DNSServiceErrorType DNSSD_API DNSServiceQueryRecord
(
DNSServiceRef *sdRef,
DNSServiceFlags flags,
uint32_t interfaceIndex,
const char *fullname,
uint16_t rrtype,
uint16_t rrclass,
DNSServiceQueryRecordReply callBack,
void *context /* may be NULL */
);从…
#include <dns_util.h>实际上,我已经使用这个函数为各种DNS records..but编写了目标-c包装器,我没有时间在某个地方发布它。
发布于 2014-10-30 19:37:08
如果其他人在搜索中遇到这种情况,希望看到更多的详细信息:
我发现它来自#include <dns_sd.h>
// domain is a NSString
DNSServiceRef sdRef;
DNSServiceQueryRecord(&sdRef, 0, 0, [domain UTF8String], kDNSServiceType_MX, kDNSServiceClass_IN, callBack, NULL);
DNSServiceProcessResult(sdRef);
DNSServiceRefDeallocate(sdRef);这是为了如果您想要MX记录作为一个域。callBack是一种C方法
static void callBack(
DNSServiceRef sdRef,
DNSServiceFlags theFlags,
uint32_t theInterfaceIndex,
DNSServiceErrorType theErrorCode,
const char* theName,
uint16_t theType,
uint16_t theClass,
uint16_t theDataLength,
const void* theData,
uint32_t theTTL,
void* theContext)
{
// do your magic here...
}回调方法一旦找到响应,就会被调用,请注意,您可以接收多个回调。例如,当我检查我的办公室电子邮件域时,我收到了7次回电。
https://stackoverflow.com/questions/5376973
复制相似问题