does anyone know of any examples of avahi discovery in c/c++?
For my C++ home automation daemon, I needed to advertise and discover services via Avahi and wrote a Discovery class for that.
It's not generic, ready-to-use sample code, and is not completely free of dependencies. In particular, it uses the
MLTicketclass from p44utils to implement regular calls to
avahi_polland for delaying advertisement.
But I guess it could still be of use for you to see how to set up and run avahi from C++ in general, and for an example of a wrapper class for a service browser (
ServiceBrowserclass near the end of the source file).
The code is such that it is normally linked against the avahi client library
libavahi-client(the normal case on the Omega2, that's when the avahi daemon process is running and your app is one of possibly multiple clients using avahi services).
But when you define
USE_AVAHI_COREas non-zero, then the code can also be linked against the avahi core library, which can be handy on really tiny embedded systems where your app is the only avahi user and you don't want the overhead of the separate avahi daemon.
@luz Why thank you! That's just what I was looking for. Perfect to learn from.