Coder Social home page Coder Social logo

poco-dnssd's Introduction

POCO DNS-SD (Zeroconf) Wrapper Library for Bonjour and Avahi

This is a POCO-based wrapper library providing an easy-to-use and unified programming interface to Apple Bonjour and Avahi libraries implementing DNS Service Discovery (DNS-SD, also known as Zeroconf).

Prerequisites

The Apple Bonjour SDK is needed on Windows (and OS X, of course). The Avahi client libraries are needed on Linux.

Getting Started

Clone into the root of an existing POCO source tree. The POCO Foundation and Net libraries are required.

$ git clone https://github.com/pocoproject/poco-dnssd.git DNSSD

On Windows, build the included Visual C++ solution. On Linux/OS X, build with POCO_BASE environment variable set to the root of the POCO source tree.

$ export POCO_BASE=`pwd`
$ cd DNSSD
$ make -s -j8
$ make -s -j8 -C Default

See the doc directory for documentation and the samples directory for sample applications.

License

Boost Software License 1.0

poco-dnssd's People

Contributors

obiltschnig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

poco-dnssd's Issues

Handling of subtypes. Record names miss subtype information. Service name presented by ServiceEventArgs

As described in the documentation of the Service class, subtypes are defined in the domain string and are seperated by comma from the domain name: Example of such a string is "_bacnet._tcp,dev".

I added/defined a service using the following line of code:
Poco::DNSSD::Service serviceDEV1(ni.index(), "1-4711", "", "_bacnet._tcp,dev", "", "", 8080, propsDEV);

Using wireshark it is recordable that there are records propagated that will inform about the defined/used subkey: "dev._sub._bacnet._tcp.local: type PTR, class IN, 1-4711._bacnet._tcp.local" but the records like SRV and TXT miss the subkey information in the recoreds name. There is only "1-4711._bacnet._tcp.local: type SRV, class IN, ..." and "1-4711._bacnet._tcp.local: type TXT, class IN, ..." instead of "1-4711.dev._sub._bacnet._tcp.local: type SRV, class IN, ..." and "1-4711.dev._sub._bacnet._tcp.local: type TXT, class IN, ..." as I would expect.

But to get such a record on the wire (visible to wireshark) using the name with the subkey information, I need to create the service element that way:
Poco::DNSSD::Service serviceDEV1(ni.index(), "1-4711.dev._sub", "", "_bacnet._tcp,dev", "", "", 8080, propsDEV);

But when I request information from the DNSSD system I get it via the event OnServiceResolved the Service data of the ServiceEventArgs return as Name "1-4711.dev._sub" and as FullName "1-4711.dev._sub._bacnet._tcp.local." (There are backslashes for escaping?). The FullName with its escaping characters is not what I expected.

Is there any issue in handling the Service class (from my side) to get the library handling subtypes as expected or is there a bug inside the library?

TestDNSSD.cpp.txt It is the code of my testapplication
TestDNSSD Output.txt It is the output of the application
TestDNSSD Wireshark.pcapng.txt The wireshark trace. Was not able to load a ZIP file. Remove the txt extension of pcapng file and hope it is not damaged.

dns_sd.h is missed. Compile of DNSSD/Bonjour fails

To compile the DNSSD library I included the poco-dnssd-master folder into the poco-1.7.4-all folder and renamed it to DNSSD. Additionally I added "DNSSD" to the component file and startet the windows-build. The DNSSD libraries were build without any errors but the DNSSD/Bonjour failed, because the file dns_sd.h is missed.
Where to get the dns_sd.h file?

This is the first error line:
1>E:\poco-1.7.4-all\DNSSD\Bonjour\include\Poco/DNSSD/Bonjour/EventLoop.h(30): fatal error C1083: Cannot open include file: 'dns_sd.h': No such file or directory [E:\poco-1.7.4-all\DNSSD\Bonjour\Bonjour_vs100.vcxproj]

The calling of serviceResolved for a particular service is incrementally increased

ITNOA

Hi,

I have a main code like below

dnssd_responder.start();

dnssd_responder.browser().serviceFound += Poco::delegate(on_service_found);
dnssd_responder.browser().serviceResolved += Poco::delegate(on_service_resolved);

Poco::DNSSD::Service service("_test._udp", 3000);

dnssd_responder.browse().browse("_test._udp", "local");

auto service_handle = dnssd_responder.registerService(service);
std::this_thread::sleep_for(3s);
dnssd_responder.unregisterService(service_handle);
service_handle = dnssd_responder.registerService(service);
dnssd_responder.unregisterService(service_handle);

and i have a simple implementaion for event handlers like below

void on_service_found(const void* sender, const Poco::DNSSD::DNSSDBrowser::ServiceEventArgs& arguments)
{
    reinterpret_cast<Poco::DNSSD::DNSSDBrowser*>(const_cast<void*>(sender))->resolve(arguments.service));
}

void on_service_resolved(const void* sender, const Poco::DNSSD::DNSSDBrowser::ServiceEventArgs& arguments)
{
    static int a = 0;
    std::cout << "number of on service resolved calls: " << ++a << std::endl;
}

I expect that after the run program i see 2 line and last a equal to 2, but i see 3 line and last a equal to 3.

I think the problem is resolver run in background continuously, for each on_service_found called and it does not stop after new resolve called. However, the documentation of resolve method in DNSSDBrowser.h file says: "After either the serviceResolved or resolveError event has been fired, the returend BrowseHandle is no longer valid" so i think resolve will be stop after fire serviceResolved, But it does not follow behavior that i guess.

I have two question about that:

  1. Is this an bug or not?
  2. If this does not a bug, so what is the solution for call on_service_resolve only twice?

thanks a lot

Building project

how can build source in ubuntu 20.04?
I make a mistake whenever I try to build project.

If possible, guide me on how to build the project

Build Problem while building Default

I am getting following error while doing
make -s -j8 Default:

make -s -j8 -C Default
** Creating dependency info for src/AvahiBrowserImpl.cpp
** Creating dependency info for src/AvahiResponderImpl.cpp
In file included from include/Poco/DNSSD/Avahi/AvahiResponderImpl.h:23:0,
from src/AvahiResponderImpl.cpp:17:
include/Poco/DNSSD/Avahi/Avahi.h:25:30: fatal error: Poco/DNSSD/DNSSD.h: No such file or directory
In file included from include/Poco/DNSSD/Avahi/AvahiBrowserImpl.h:23:0,
from src/AvahiBrowserImpl.cpp:17:
include/Poco/DNSSD/Avahi/Avahi.h:25:30: fatal error: Poco/DNSSD/DNSSD.h: No such file or directory
compilation terminated.
compilation terminated.
** Compiling src/AvahiBrowserImpl.cpp (debug, shared)
** Compiling src/AvahiResponderImpl.cpp (debug, shared)
** Compiling src/AvahiBrowserImpl.cpp (release, shared)
** Compiling src/AvahiResponderImpl.cpp (release, shared)
In file included from include/Poco/DNSSD/Avahi/AvahiBrowserImpl.h:23:0,
from src/AvahiBrowserImpl.cpp:17:
include/Poco/DNSSD/Avahi/Avahi.h:25:30: fatal error: Poco/DNSSD/DNSSD.h: No such file or directory
compilation terminated.
In file included from include/Poco/DNSSD/Avahi/AvahiResponderImpl.h:23:0,
from src/AvahiResponderImpl.cpp:17:
include/Poco/DNSSD/Avahi/Avahi.h:25:30: fatal error: Poco/DNSSD/DNSSD.h: No such file or directory
In file included from include/Poco/DNSSD/Avahi/AvahiResponderImpl.h:23:0,
from src/AvahiResponderImpl.cpp:17:
include/Poco/DNSSD/Avahi/Avahi.h:25:30: fatal error: Poco/DNSSD/DNSSD.h: No such file or directory
compilation terminated.
compilation terminated.
/home/abhi/Downloads/poco/build/rules/compile:51: recipe for target '/home/abhi/Downloads/poco/DNSSD/Avahi/obj/Linux/x86_64/debug_shared/AvahiBrowserImpl.o' failed
make[1]: *** [/home/abhi/Downloads/poco/DNSSD/Avahi/obj/Linux/x86_64/debug_shared/AvahiBrowserImpl.o] Error 1
make[1]: *** Waiting for unfinished jobs....
/home/abhi/Downloads/poco/build/rules/compile:55: recipe for target '/home/abhi/Downloads/poco/DNSSD/Avahi/obj/Linux/x86_64/release_shared/AvahiResponderImpl.o' failed
make[1]: *** [/home/abhi/Downloads/poco/DNSSD/Avahi/obj/Linux/x86_64/release_shared/AvahiResponderImpl.o] Error 1
/home/abhi/Downloads/poco/build/rules/compile:51: recipe for target '/home/abhi/Downloads/poco/DNSSD/Avahi/obj/Linux/x86_64/debug_shared/AvahiResponderImpl.o' failed
make[1]: *** [/home/abhi/Downloads/poco/DNSSD/Avahi/obj/Linux/x86_64/debug_shared/AvahiResponderImpl.o] Error 1
In file included from include/Poco/DNSSD/Avahi/AvahiBrowserImpl.h:23:0,
from src/AvahiBrowserImpl.cpp:17:
include/Poco/DNSSD/Avahi/Avahi.h:25:30: fatal error: Poco/DNSSD/DNSSD.h: No such file or directory
compilation terminated.
/home/abhi/Downloads/poco/build/rules/compile:55: recipe for target '/home/abhi/Downloads/poco/DNSSD/Avahi/obj/Linux/x86_64/release_shared/AvahiBrowserImpl.o' failed
make[1]: *** [/home/abhi/Downloads/poco/DNSSD/Avahi/obj/Linux/x86_64/release_shared/AvahiBrowserImpl.o] Error 1
Makefile:21: recipe for target 'projects' failed
make: *** [projects] Error 2

Building static only

Building on OS X 10.13.6.

I can get the non-implementation code to build statically using:

make -s -j8 static_debug static_release

But doing the same for the implementation code fails:

make -s -j8 -C Default static_debug static_release

The error is:

~/vs-dev/vendor/poco/src/poco-1.9.0/DNSSD ~/vs-dev/build/poco/osx/1.9.0 ~/vs-dev/vendor/poco
make: *** No rule to make target `static_debug'.  Stop.

Which is weird as there is a static_debug: target in .../build/rules/lib.

Data of additional TXT records not propagated by serviceResolved event

Created a Service instance incl. the properties parameter and registered it via the DNSSDResponder.

Poco::DNSSD::Service::Properties propsDEV2;
propsDEV2.add("txtvers", "1");
propsDEV2.add("wss-2", "/bacnet0815");
propsDEV2.add("prio-2", "1000");
propsDEV2.add("ttl-2", "300");
propsDEV2.add("rq-2", "3");

Poco::DNSSD::Service serviceDEV2(ni.index(), "1-0815.dev._sub", "", "_bacnet._tcp,dev", "", "", 8080, propsDEV2);
serviceHandleDEV2 = dnssdResponder.registerService(serviceDEV2);

Created a second Record and added it to the registered service.

char *propsDevString2 = "\x9txtvers=1\xewss-6=/bacnet2\xbprio-6=1000\x9ttl-6=500\x6rq-6=3";
Poco::DNSSD::Record rec2("1-0815.dev._sub._bacnet._tcp.local", Poco::DNSSD::Record::RT_TXT, 54, propsDevString2);
Poco::DNSSD::RecordHandle recordHandle2 = dnssdResponder.addRecord(serviceHandleDEV2, rec2);

Using wireshark I can see that both TXT records are propagated if I browse and resolve the service, but when iterating through the properties list (ServiceEventArgs::service.properties()) only the properties of the TXT Record created while creating the Service class instance are listed in properties, but the key-value-pairs of the second TXT Record added to the registered service are not included in the properties list (keys are all distinguishable).

Why is the data of the second TXT record not listed in the properties list?
Is it related to the handling of subkeys as described in issue #2? Could the second record not associated to the first record and the service?

View to wireshark trace the naming of the records look correct.

Please help cross compile DNSSD

I am trying to cross compile for arm. I have successfully compiled poco for arm using:

./configure --config=ARM-Linux --no-samples --no-tests --include-path=....... --library-path=...... --prefix=....... --everything
I have edited ARM-linux as required.

Following the steps mentioned in README DNSSD compiles but for x86. How to compile DNSSD just like any other component like JSON. They have the same makefile, How to make POCO_BASE pickup DNSSD like others. I tried adding to components like this:

CppUnit
CppUnit/WinTestRunner
Foundation
Encodings
XML
JSON
Util
Net
DNSSD
DNSSD/Avahi
DNSSD/Default

That did not pick up DNSSD.

Please help

Modifying TXT records created by Service class is not possible!?

When creating a new Service class the constructor will accept a properties parameter. The content is put into a TXT record associated to the SRV record.

But is there any way to modify this record after service is registered via Poco::DNSSD::DNSSDResponder::registerService? There is no Poco::DNSSD::RecordHandle returned that can be used to call Poco::DNSSD::DNSSDResponder::updateRecord.

I created a Service instance without passing properties parameters to the Ctor and added a Record afterwards via Poco::DNSSD::DNSSDResponder::addRecord. But the result is, that there is automatically created an empty TXT record when the service is registered. This Record is of type TXT and has a TXT length of zero.

Have a look at frame number 11. There you can see the two TXT records. On is the empty one that was created when the service was added.
TestDNSSD Wireshark.pcapng.txt The wireshark trace. Was not able to load a ZIP file. Remove the txt extension of pcapng file and hope it is not damaged.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.