views:

48

answers:

1

Bonjour provides "DNSSD.browse(serviceType,callBackObject)" method which browses for services of a particular type. If a service of the given type is found, Bonjour calls "callBackObject.serviceFound". If the service is lost, Bonjour calls "callBackObject.serviceLost".

I alway considered "DNSSD.browse" as a method for monitoring a particular service. Bonjour monitors a particular service and calls necessary method if the service is found (available) or lost (not available).

But than I realized that "DNSSD.browse" receives (as argument) a type of service (for example "http.tcp") and there can be several services of this type. So, its probably calls "serviceFound" and "serviceLost" if any service of the specified type is found or lost, respectively.

But in my application I would like to browse just for one particular service. What is the best way to do it? I have two potential solutions:

  1. When I register a service, I give it a unique type. For example: "server1.http.tcp".

  2. I register services with unique names (not types) and ask Bonjour to browse for services with particular names. But I am not sure that Bonjour provide such possibility. Can it browse for services with specific names?

+1  A: 

Your first option strikes me as the best one. Service names can have a service instance name added to them so your service could have the name you suggest (but with appropriate underscores), "server1._http._tcp". With that service name the service should show up when browsing for "_http._tcp" and for "server1._http._tcp" if you want a more particular query. DNSSD.browse should have full support for service names of this type.

Per Ekman