Creating an echo client that uses Bonjour to discover the service

In the previous recipe, we used the CFSocketServer and BonjourPublishServices classes to create an echo server and to publish it. In this recipe, we will be using CFSocketClient, BonjourBrowserService, and BonjourResolverService to find the echo server and to connect to it.

The downloadable code for this chapter contains a BonjourEchoClient project that will search for servers published by the BonjourEchoServer project, which was covered in the Creating an echo server that uses Bonjour to advertise the service recipe, and then we will send a text string to the server. The server should respond back with the same string that we sent.

If the client is unable to find any published echo ...

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.