I was searching for a possibility to query SRV DNS records in C/C++. As always, there are high-level library functions (ldns, libunbound), but I didn’t want to introduce another dependency. So I’m using the many years old functions originally provided by BIND (now included in glibc). The man pages aren’t that helpful as they are incomplete. I found most information here and by debugging.

This was quite a bit work, so I would like to share it with you here.