Question

I register a Bonjour service using

DNSServiceRegister(&dnssref, 0, 0, "Fortune Server on my-PC", "_trollfortune._tcp", 0, 0, bigEndianPort, 0, 0, 0, 0);

I then browse for it using

DNSServiceBrowse(&dnssref, 0, 0, "_trollfortune._tcp", 0, bonjourBrowseReplyCallback, this);

My callback function is called twice, with the same serviceName, regType and replyDomain, only the interfaceIndex is different, the first time it's 20, the second time it is 10000010. if_indextoname() returns ethernet_12 for both.

At the same time, Bonjour Browser (a tool I found on the Internet) shows my service listed only once.

Am I calling DNSServiceBrowse with wrong parameters?

Was it helpful?

Solution

I found the problem in my case.

The problem started after installing VMware. It created some virtual network interfaces. After disabling those interfaces the browser only showed one result.

But I think the problem is not related to the browsing. I think the problem is with the flag kDNSServiceInterfaceIndexAny (0 - 3rd parameter) send to the function DNSServiceBrowse maybe you need to set the interface to a fixed value instead of 0.

OTHER TIPS

I found out that there is a command-line tool called dns-sd that ships with Bonjour, and you can register/browse services with it.

I registered a service using

dns-sd -R "Fortune Server on my-PC" _trollfortune._tcp local 1234

and browsing for it with the command

dns-sd -B _trollfortune._tcp

gives me the following output:

Browsing for _trollfortune._tcp
Timestamp     A/R     Flags if       Domain                    Service Type              Instance Name
19:48:23.674  Add     3     20       local.                    _trollfortune._tcp.       Fortune Server on my-PC
19:48:23.674  Add     2     10000010 local.                    _trollfortune._tcp.       Fortune Server on my-PC

Since the standard tool that comes with Bonjour lists the service twice, I guess this is the normal behavior.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top