2

I'm coding a C++ library that, among other things, needs to:

  • Search for a specific service in a network using AVAHI
  • Publish itself as a service using AVAHI

I've been searching for existent options. I've found that the creators of POCO C++ offer a DNS-SD library integrated with POCO C++. That would work, because I'm actually using POCO C++, but it's a commercial library, and I can't afford it.

Apart from that, avahi-daemon offers a client interface that allows browsing services and publishing new ones. It also sounds good, but I need my code to be portable, and work in major Linux distributions, Mac OS X and Windows. AFAIK, this solution would only cover Linux (where avahi-daemon is available).

I guess as partial solution, I could just send a properly formatted message via socket and process the raw response. That way, I could search for services published using AVAHI. But I think that's ugly and unmaintainable.

So, is there any good-enough solution for this without buying a software? I know this can be done using Python, but I need to do it in C++.

Many thanks in advance

Community
  • 1
  • 1
Jorge Arévalo
  • 2,858
  • 5
  • 36
  • 44
  • 1
    You can use the libdns-sd-compat header, you can integrate this easily in C++ with CMake and the hunter package manager which supports avahi as dependency, see an example : https://github.com/ruslo/hunter/blob/master/examples/Avahi/CMakeLists.txt#L16 https://github.com/ruslo/hunter – daminetreg Sep 21 '15 at 15:02

1 Answers1

1

There is an Open Source library (released under the LGPL) available over at http://avahi.org/. It exposes a C interface that can be very easily used in a c++ program.

There are also prebuilt binary version available for all major distros.

vidstige
  • 12,492
  • 9
  • 66
  • 110