Open
Description
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:
- Is this an bug or not?
- If this does not a bug, so what is the solution for call
on_service_resolve
only twice?
thanks a lot
Metadata
Metadata
Assignees
Labels
No labels