The calling of serviceResolved for a particular service is incrementally increased

Please post support and help requests here.
soroshsabz
Posts: 2
Joined: 14 Sep 2017, 19:51

The calling of serviceResolved for a particular service is incrementally increased

Postby soroshsabz » 14 Sep 2017, 19:57

ITNOA

Hi,

I have a main code like below

Code: Select all

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

Code: Select all

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?

I create a new issue on github https://github.com/pocoproject/poco-dnssd/issues/7 but I did not have enough hope to get an answer there

thanks a lot

Return to “Support”

Who is online

Users browsing this forum: No registered users and 2 guests

cron