2

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?

4

1 に答える 1

1

あなたの最初の選択肢が最良の選択肢だと思います。サービス名にはサービス インスタンス名を追加できるため、サービスには、提案した名前 (ただし、適切なアンダースコアを使用) である "server1._http._tcp" を付けることができます。このサービス名を使用すると、"_http._tcp" をブラウズしたときにサービスが表示され、さらに特定のクエリが必要な場合は "server1._http._tcp" が表示されます。DNSSD.browse は、このタイプのサービス名を完全にサポートする必要があります。

于 2010-03-15T08:24:53.377 に答える