It's not clear what you're trying to do. Have you tried using
DNSServiceBrowse()? Are you using DNSServiceRegister() to advertise
your services?
I use DNSServiceRegister to advertise my services and I need a
mechanism to find them back (but there might be more than one of them
with the same name
You can't have multiple services with the same name.
DNSServiceRegister() will automatically rename your service name if it
detects a name conflict. You should pick your own service type, like
_olger._tcp, and then browse for that type. Calling
DNSServiceBrowse() is equivalent to calling DNSSerivceQueryRecord()
and asking for PTR records with the name "_olger._tcp.local."
Right, everything comes together now. Thanks for the patience and the
explanations. I concluded that it was possible to have 2 services with
the same name available and thought to get those by using the
QueryRecord to get both. Other explanations regarding this point (of
half a year ago) are now more clear too.
The reason why your DNSServiceQueryRecord() call is failing is because
you're asking for PTR records, but you need to be asking for SRV or
TXT records. It's easier to just use DNSServiceResolve().
I will use ServiceBrowse and use the result with ServiceResolve() as
you say, that is much easier (and more clear for others to understand
what is going on)