AsyncFw 1.2
Async Framework is c++ runtime with timers, poll notifiers, sockets, coroutines, etc.
 
Loading...
Searching...
No Matches
MulticastDns/main.cpp

MulticastDns example

/*
Copyright (c) 2026 Alexandr Kuzmuk
This file is part of the AsyncFw project. Licensed under the MIT License.
See {Link: LICENSE file https://mit-license.org} in the project root for full license information.
*/
#include <AsyncFw/MulticastDns>
#include <AsyncFw/MainThread>
#include <AsyncFw/Timer>
#include <AsyncFw/LogStream>
using namespace AsyncFw;
int main(int argc, char *argv[]) {
MulticastDns _mdns {"AsyncFw_mdns_example_service"};
_mdns.hostAdded([](const MulticastDns::Host &host) { lsInfoGreen() << "Added" << host.name << host.ipv4 << host.llipv4 << host.misc << host.port; });
_mdns.hostChanged([](const MulticastDns::Host &host) { lsInfoMagenta() << "Changed" << host.name << host.ipv4 << host.llipv4 << host.misc << host.port; });
_mdns.hostRemoved([](const MulticastDns::Host &host) { lsInfoRed() << "Removed" << host.name << host.ipv4 << host.llipv4 << host.misc << host.port; });
_mdns.startService("AsyncFw_host", "AsyncFw_misc_string", 18080);
_mdns.startQuerier(1);
Timer::single(10, [&_mdns]() { _mdns.stopService(); });
Timer::single(20, [&_mdns]() { MainThread::exit(); });
lsNotice() << "Start Applicaiton";
int ret = MainThread::exec();
lsNotice() << "End Applicaiton" << ret;
return ret;
}
The MulticastDns class.
Definition MulticastDns.h:10
static void single(int ms, T function)
Starts a single shot timer with the specified timeout.
Definition Timer.h:19