CFHost
Virtually all network-orientated applications require host name lookup, such as with gethostbyname2() described in Chapter 14: Network Programming With Sockets. Unfortunately, the standard Unix domain name lookup functions are blocking, which causes the same problems with GUI unresponsiveness and application termination as discussed earlier.
The Core Services framework provides CFHost which does runloop-based host name lookup. You can use CFHost to look up addresses (mapping hostnames to an IP address) or names (mapping an IP address to a set of hostnames). You look up addresses by creating a CFHost and giving it the hostname you are interested in. Then set the “client,” which is a callback function and a context block like the socket ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access