pocoproject / poco-dnssd Goto Github PK
View Code? Open in Web Editor NEWPOCO DNS-SD (Zeroconf) Wrapper Library for Bonjour and Avahi
License: Other
POCO DNS-SD (Zeroconf) Wrapper Library for Bonjour and Avahi
License: Other
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.
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.
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
ITNOA
I think it is appreciate that merge this library into main poco library.
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
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:
on_service_resolve
only twice?thanks a lot
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]
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.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.