Rss

Bonjour, Bonjour

Short note before hauling the family over to Michigan’s Adventure, en route to Torch Lake. I wrote the last example for the networking chapter on Monday, a simple exercise in service browsing with Bonjour (né Rendezvous, aka ZeroConf). I was already a fan of highly-dynamic, service-discovery-based networking from Jini many years ago. Bonjour is much less ambitious than Jini, whose money shot is in providing appropriate executables to callers at runtime, but in many ways, Bonjour is particularly useful for network services we already have (a remarkably large number of which are already defined).

The thing that surprised me is that there’s a point at which Bonjour ends, namely, once you’ve discovered and resolved a service. After this, you have a host, a port, and some optional metadata, and it’s up to you as the caller to begin a protocol-specific conversation with the service on that port. In theory, that sounds like you’re being asked to open up sockets and go into low-level BSD mode (or CFNetwork, at least), but not necessarily: the service description could indicate that you use HTTP on some non-80 port, for which Cocoa provides convenience classes. In this case, you’d basically have a LAN webservice, one which would be very easy to write both ends of (I’m tempted to do a quick one-off Bonjour chat app, in which the peers post messages to each other with HTTP POSTs).

For the book example, in order to keep the focus on the service discovery and not the socketry, Daniel suggested I just browse the Bonjour-exposed Apache web servers on local Macs, and load their first pages into an iPhone web view. This turned out to be pretty simple and very clear in showing the key Bonjour steps. I think this is going to be a nice chapter when I finish writing the last section.

Next… not sure, but for a break from APIs, I may do performance and debugging (and probably app-signing to put your app on the device, since that’s currently broken on the laptop and I’ll therefore have to go through all those steps for myself again anyways).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.