Queries for the IP address of a hostname by using either Multicast or Unicast DNS.
- iOS 9.3+
- macOS 10.11.4+
- Mac Catalyst 13.0+
- tvOS 9.2+
- watchOS 2.2+
kDNSServiceFlagsForceMulticast or kDNSServiceFlagsLongLivedQuery. Pass kDNSServiceFlagsLongLivedQuery to create a "long-lived" unicast query to a unicast DNS server that implements the protocol. This flag has no effect on link-local multicast queries.
The interface on which to issue the query. Passing 0 causes the query to be sent on all active interfaces via Multicast or the primary interface via Unicast.
kto look up IPv4 addresses, or kDNSServiceProtocol_IPv6 to look up IPv6 addresses, or both to look up both kinds. If neither flag is set, the system will apply an intelligent heuristic, which is (currently) that it will attempt to look up both, except:
DNSService Protocol _IPv4
* If "hostname" is a wide-area unicast DNS hostname (i.e. not a ".local." name) but this host has no routable IPv6 address, then the call will not try to look up IPv6 addresses for "hostname", since any addresses it found would be unlikely to be of any use anyway. Similarly, if this host has no routable IPv4 address, the call will not try to look up IPv4 addresses for "hostname".
The fully qualified domain name of the host to be queried for.
The function to be called when the query succeeds or fails asynchronously.
An application context pointer which is passed to the callback function (may be NULL).
k on success (any subsequent, asynchronous errors are delivered to the callback), otherwise returns an error code indicating the error that occurred.