Discovering a Bonjour service
In this recipe, we will use the
NSNetServiceBrowser
class to look for our published service.
The NSNetServiceBrowser
class is used to find the services that are published by NSNetService
. Once we initialize the NSNetServiceBrowser
object, we need to assign a delegate, and then we can begin browsing for services. Taking into account the possibility of delays in receiving responses from the services and also because services can come online or go offline at any time, the NSNetServiceBrowser
object performs the service discovery asynchronously. The NSNetServiceBrowser
class relies on the delegate methods to handle the notifications of the services coming online or going offline.
Getting ready
This recipe is compatible ...
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.