Can Bonjour browse a service with a particular name?

Posted by Roman on Stack Overflow See other posts from Stack Overflow or by Roman
Published on 2010-03-14T13:22:06Z Indexed on 2010/03/14 13:25 UTC
Read the original article Hit count: 283

Filed under:
|
|
|

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 call "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?

© Stack Overflow or respective owner

Related posts about java

Related posts about networking