O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required