Search code examples
c++bonjour

DNSServiceBrowse lists the same service twice, with different interfaceIndex


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?


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.