QMdnsEngine  0.1.0
Multicast DNS library for Qt applications
Signals | Public Member Functions | List of all members
QMdnsEngine::Browser Class Reference

Browser for local services More...

#include <qmdnsengine/browser.h>

Inheritance diagram for QMdnsEngine::Browser:

Signals

void serviceAdded (const Service &service)
 Indicate that a new service has been added. More...
 
void serviceRemoved (const Service &service)
 Indicate that the specified service was removed. More...
 
void serviceUpdated (const Service &service)
 Indicate that the specified service was updated. More...
 

Public Member Functions

 Browser (AbstractServer *server, const QByteArray &type, Cache *cache=0, QObject *parent=0)
 Create a new browser instance. More...
 

Detailed Description

This class provides a simple way to discover services on the local network. A cache may be provided in the constructor to store records for future queries.

To browse for services of any type:

QMdnsEngine::Browser browser(&server, QMdnsEngine::MdnsBrowseType);

To browse for services of a specific type:

QMdnsEngine::Browser browser(&server, "_http._tcp.local.");

When a service is found, the serviceAdded() signal is emitted:

connect(&browser, &QMdnsEngine::Browser::serviceAdded, [](const QMdnsEngine::Service &service) {
qDebug() << "Service added:" << service.name();
});

The serviceUpdated() and serviceRemoved() signals are emitted when services are updated (their properties change) or are removed, respectively.

Constructor & Destructor Documentation

◆ Browser()

QMdnsEngine::Browser::Browser ( AbstractServer server,
const QByteArray &  type,
Cache cache = 0,
QObject *  parent = 0 
)
Parameters
serverserver to use for receiving and sending mDNS messages
typeservice type to browse for
cacheDNS cache to use or null to create one
parentQObject

Member Function Documentation

◆ serviceAdded

void QMdnsEngine::Browser::serviceAdded ( const Service service)
signal

This signal is emitted when the PTR and SRV records for a service are received. If TXT records are received later, the serviceUpdated() signal will be emitted.

◆ serviceRemoved

void QMdnsEngine::Browser::serviceRemoved ( const Service service)
signal

This signal is emitted when an essential record (PTR or SRV) is expiring from the cache. This will also occur when an updated PTR or SRV record is received with a TTL of 0.

◆ serviceUpdated

void QMdnsEngine::Browser::serviceUpdated ( const Service service)
signal

This signal is emitted when the SRV record for a service (identified by its name and type) or a TXT record has changed.


The documentation for this class was generated from the following file: