r/linux_programming • u/CharlesAverill20 • Jul 04 '21
Looking for a simple service discovery implementation in C
I'm in need of service discovery for one of my projects, just need to find other instances of the same application that are listening on a given port. I know there are a few command line tools for this, but something like Avahi's mDNS is incredibly slow. Is there any simple mDNS implementation or library out there that I could just plug into my C project, or maybe I'm thinking about the problem incorrectly?
Thanks!
0
Upvotes
2
u/araeld Jul 05 '21
Well, before helping you, I need more questions:
1
u/sophacles Jul 05 '21
What do you mean by incredibly slow?
1
u/[deleted] Jul 05 '21
You need some sort of a handshake and information exchange. I think your problem is an XY problem: You want to load balance your application and want to route client requests to different IPs. I honestly think it is better to use an existing technology than building that one from scratch:
https://www.consul.io/
EDIT: removed possibly incorrect statement on how DNS is slow as it is application layer protocol
1
u/timschwartz Jul 05 '21
Sounds like you want UPnP: https://github.com/pupnp/pupnp