Chapter 6. Getting Started with BonjourZeroconf


Chapter 6. Getting Started with Bonjour/Zeroconf

The previous chapters presented an overview of how the Zeroconf infrastructure works. The remainder of the book contains information on creating Zeroconf applications in a variety of settings. This chapter introduces the dns-sd command-line test tool, which lets you, the human user, perform common DNS-SD operations such as advertising services, browsing, and resolving. The dns-sd tool is not something you'd ever use in a shipping product, and it's not intended to be used from shell scripts; it's provided as a testing, development, and troubleshooting tool. It serves three main purposes.

First, if you're a developer toying with the idea of adding Zeroconf to your product, the dns-sd tool allows you to experiment with "what if" scenarios, without writing a single line of code. If your product is a network camera that already supports RTSP and RTP video streaming, then the dns-sd tool lets you create a proxy advertisement for that camera, so that you can make it appear in the Open URL...menu in QuickTime Player 7, so you can get a feel for how the user experience could be for end users if the product had native Zeroconf support. When making a project proposal to management, being able to show a demo like this, interoperating with existing real-world software, is very compelling.

Second, when you're ready to add Zeroconf to your product, the source code for the dns-sd tool (available from the Darwin open source repository) provides useful sample code to cut and paste into your application. The source code is approximately 700 lines of C, and it's basically a big switch statement with one case for each of the common DNS-SD operations. After prototyping by running the dns-sd tool with the appropriate command-line option for the operation your application needs to do, you can then find that particular case in the switch statement and copy that chunk of example code into your application.

Third, after you've added Zeroconf to your product, if you're troubleshooting problems, the dns-sd tool can provide a useful independent verification of whether your software is working correctly. If your product is one that advertises a service, then you can use dns-sd -B to verify that the service appears. If your product is one that browses for services, then you can use dns-sd -R to create advertisements and verify that they appear in your application when you run the command and then disappear when you stop it with Ctrl-C. If your product is one that browses for services, but it's not discovering what you think it should, you can use dns-sd -B for independent verification. If dns-sd -B shows the service but your application doesn't, then that suggests a bug in your application. If neither sees the service, that suggests a problem elsewhere.




Zero Configuration Networking. The Definitive Guide
Zero Configuration Networking: The Definitive Guide
ISBN: 0596101007
EAN: 2147483647
Year: 2004
Pages: 97

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net