https://forum.lazarus.freepascal.org/index.php/topic,57806.0.html - is this of any help?
Thank you! I read this topic. It was helpful to know about IdIPMCastServer.
I read mDNS RFC. Unfortunately, this is a very complex problem.
I think implementing the protocol from scratch would be wrong. According to the RFC, mDNS is the direct successor of DNS. And it would be the right decision to take the working version of the DNS and inherit from it.
The protocols differ only in three small changes:
- A new field (logical flag) with a length of one bit "UNICAST-RESPONSE" has been added to the mDNS Query Question. QNAME, QTYPE, QCLASS unchanged.
- The boolean flag "CACHE-FLUSH" has also been added to the Response Resource Record. The remaining fields are RRNAME, RRTYPE, RDATA, etc. same.
- The RRTYPE=TXT record format has been changed. May contain JSON etc.
As I already wrote, it turned out to be a problem to inherit from existing DNS implementations.
It seems that the only way out is to copy the IdDNSResolver component, but change the parent to IdIPMCastServer, as in your solution. You will need to clean up a lot of dependencies inside

But there all structures are already declared. And they are tested! And parsing the response, compiling a request will require adding just a couple of flags. In theory

And the implementation of DNS-SD will have to be written from scratch.
In your example, obtaining IP is too simplified.
DNS-SD is a server running under the mDNS protocol, which must be run in a separate thread and continuously listen for changes. A device (service) can change its IP address, for example, by getting another one via DHCP. And then DNS-SD should immediately report that the service has a new address. Moreover, in the response of the SRV type, not only the HostName is reported, but also the Port! Moreover, the address may not match the address from which the answer was received!
In my case, the devices report the address and port of the REST Webservice to connect to.
Also, DNS-SD should listen on the special type "_services._dns-sd._udp" and respond to requests of this type automatically.
For example, in Linux, you can find all services with the Avahi utility:
~ $ avahi-browse _services._dns-sd._udp
+ wlp0s29u1u2 IPv4 _workstation _tcp local
+ wlp0s29u1u2 IPv4 _device-info _tcp local
+ wlp0s29u1u2 IPv4 _smb _tcp local
+ wlp0s29u1u2 IPv4 _ssh _tcp local
+ wlp0s29u1u2 IPv4 _ewelink _tcp local
And then, for each ServiceType="_ewelink._tcp", get all devices:
~ $ avahi-browse _ewelink._tcp
+ wlp0s29u1u2 IPv4 eWeLink_100c46f0 _ewelink._tcp local
+ wlp0s29u1u2 IPv4 eWeLink_100c5910 _ewelink._tcp local
This was PTR query.
When DNS-SD know ServiceName "eWeLink_100c46f0._ewelink._tcp" it must form
SRV query and receive:
Hostname&Port like:
0 0 1651 eWeLink_100c46f0.local
and only then form A and AAAA querys for Hostname -> IP addr.
Not so simple.
I would like to find something already implemented and not read RFC DNS (6 big docs)

After all, in fact, my program just needs to know "192.168.0.13 : 1651".
P.S. eWeLink is iot-devices for SmartHome. Tuya have proprietry discovery UDP protocol under ports 6666 and 6667