Why avahi-browse shows more answers?
When I use avahi-browse --all I get more services than using your library. I send a request and wait for a response and this repeats in a loop. I use both ipv4 and ipv6
I assume avahi-browse uses the avahi service, so it might have caught earlier broadcasts and responses which were not sent in reply to the DNS-SD question sent by this library when you run your tests?
You could set breakpoints in mdns_discovery_recv on the early outs (lines with return 0) and see if some answer records are being discarded, and why.
I use the program Wireshark, and I get the impression that avahi-browse is reading what comes at 224.0.0.251.
That's the multicast IPv4 address, yes. However, responses to DNS-SD queries should be sent unicast. This library does not (yet) listen to multicast announces.
Clarification, the library listens to multicast queries when in listening mode (acting as a server), but not to multicast annouces for service discovery (acting as a client)