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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.