Book Image

iOS and OS X Network Programming Cookbook

By : Jon Hoffman
Book Image

iOS and OS X Network Programming Cookbook

By: Jon Hoffman

Overview of this book

Table of Contents (15 chapters)
iOS and OS X Network Programming Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Publishing a Bonjour service


Bonjour allows for the discovery of network devices and services on an IP network without a centralized server. In this recipe, we will create a class called BonjourPublishServices that will contain the code needed to publish a service with NSNetService.

The NSNetService class is normally used to publish information about a socket server. While it is also typical for NSNetService and the socket server to be running within the same application, it is not a requirement since NSNetService does not use, nor is it dependent on the socket server in any way.

As the publication of the service may not happen instantaneously, NSNetService should publish the request asynchronously. NSNetService uses delegate methods to handle the notifications of the service publication. Each delegate method receives an NSNetService object that identifies the service calling the method; therefore, one delegate can handle multiple services.

Tip

While it is possible for one delegate to manage...