Chapter 9. Using the CFNetwork and Cocoa APIs

In the previous three chapters, you have learned about techniques and APIs that work on multiple platforms. In Chapter 6, we covered the general concepts and the dns-sd command-line tool, which apply to all the supported platforms. In Chapter 7 we covered the DNSServiceDiscovery C API, which is available on all the supported platforms. In Chapter 8, you saw the Java API, which lets you write a Java program that will run on any supported platform with Java installed.

If you’re writing a program in C that’s built around a Core Foundation CFRunLoop as its central event-handling mechanism, or a program in Objective-C that’s built around a Cocoa RunLoop as its central event-handling mechanism, you have two options. The first option is that you can use the standard C DNSServiceDiscovery API and add those active operations as event sources to your RunLoop, as shown in the Core Foundation and Cocoa examples toward the end of Chapter 7. If you’re comfortable mixing standard C in with your Core Foundation-style or Cocoa-style programming, this is fine. However, if you prefer to stick to a single programming style, then you have a second option: Apple has provided additional wrapper APIs that follow the Core Foundation and Cocoa idioms.

In this chapter, you will look at how to perform the basic DNS-SD operations of registering a service, browsing for services, and resolving a service using these Mac OS X-specific APIs, which Apple has provided for ...

Get Zero Configuration Networking: The Definitive Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.