Creating an echo server that uses Bonjour to advertise the service

Now that we know how to publish, find, and resolve a service, let's put it all together with an actual service to connect to. In this recipe, we will take the echo server that we created in Chapter 2, Apple Low-level Networking, and add the code to publish the service with Bonjour.

The downloadable code for this chapter contains an iOS application that uses both the CFSocketServer class (from Chapter 2, Apple Low-level Networking) and the BonjourPublishServices class (from this chapter). The application, once the user clicks on the Start button, will attempt to publish the service; however, the echo server will start when the application first starts up. Keep in mind that publishing ...

Get iOS and OS X Network Programming Cookbook now with O’Reilly online learning.

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