Question

I've built the Qt+Bonjour integration demo from Qt Quarterly, but one thing I can't wrap my head around is that a single call to DNSServiceProcessResult() is calling the DNSServiceResolveReply callback function twice.

It should be calling it once! What I mean is, this single line:

DNSServiceErrorType err = DNSServiceProcessResult(dnssref);

Results in the DNSServiceResolveReply callback I passed to DNSServiceResolve to be called twice.

The interfaceIndex is different - first time it is 10000010, second time it is 20, but I have no idea what that means.

All other parameters are the same between calls (except flags, of course, which is kDNSServiceFlagsMoreComing the first time and 0 the second).


Edit

This is how I call the DNSServiceResolve function.

DNSServiceErrorType err = DNSServiceResolve(&dnssref, 0, 0,
                                            record.serviceName.toUtf8().constData(),
                                            record.registeredType.toUtf8().constData(),
                                            record.replyDomain.toUtf8().constData(),
                                            (DNSServiceResolveReply)bonjourResolveReply, this);
Was it helpful?

Solution

I found the problem, it was that I was passing 0 for the interfaceIndex when calling DNSServiceResolve.

The docs say that:

If this resolve call is as a result of a currently active DNSServiceBrowse() operation, then the interfaceIndex should be the index reported in the DNSServiceBrowseReply callback. If this resolve call is using information previously saved (e.g. in a preference file) for later use, then use interfaceIndex 0, because the desired service may now be reachable via a different physical interface.

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