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 ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.