Thank you for the response.
I was trying to write a poc and validate this with the following code:
import Foundation
import dnssd
var vSDRef: DNSServiceRef?
let callback: DNSServiceGetAddrInfoReply = { (sdef, flags, interface_idx, errorcode, hostname, resolvedAddresses, ttl, context) in
NSLog("Callback called...")
if errorcode == kDNSServiceErr_NoError {
if let hostname = hostname, let address = resolvedAddresses {
var add_string = [CChar](repeating: 0, count: Int(INET6_ADDRSTRLEN))
switch Int32(address.pointee.sa_family) {
case AF_INET:
var ipv4_addr = address.withMemoryRebound(to: sockaddr_in.self, capacity: 1) { $0.pointee }
inet_ntop(AF_INET, &(ipv4_addr.sin_addr), &add_string, socklen_t(INET_ADDRSTRLEN))
case AF_INET6:
var addr6 = address.withMemoryRebound(to: sockaddr_in6.self, capacity: 1) { $0.pointee }
inet_ntop(AF_INET6, &(addr6.sin6_addr), &add_string, socklen_t(INET6_ADDRSTRLEN))
default:
NSLog("Unknown address family")
return
}
NSLog("Resolved \(String(cString: hostname)) to \(String(cString: add_string))")
} else {
NSLog("Error resolving DNS address: \(errorcode)")
}
}
}
let returned_error = DNSServiceGetAddrInfo(&vSDRef, DNSServiceFlags(kDNSServiceFlagsLongLivedQuery), 0, DNSServiceProtocol(kDNSServiceProtocol_IPv4 | kDNSServiceProtocol_IPv6), "example.com", callback, nil)
if returned_error == kDNSServiceErr_NoError {
NSLog("DNS lookup started...")
} else {
NSLog("Error starting DNS resolution: \(returned_error)")
}
NSLog("Resolved if else")
sleep (100)```
tcpdump showed that we are getting a response but the callback never gets triggered.
Can you help me out here please.
Thanks,
Harshal.