class DNSSDResponder

File Information

Library: DNSSD
Package: Core
Header: Poco/DNSSD/DNSSDResponder.h


DNSSDResponder provides a unified interface to the underlying DNS Service Discovery implementation, which can be Apple's Bonjour or Avahi.

An application should not create more than one instance of the DNSSDResponder class.

To register a service with the DNSSDResponder, and thus to announce a service on the network, create an instance of Service with appropriate values. Then pass this object to registerService(). Example:

DNSSDResponder dnssdResponder;
Service::Properties props;
Service myService(0, "My Service", "_mysvc._tcp", "", "", 1234, props);
ServiceHandle myServiceHandle = dnssdResponder.registerService(myService);

Note that service registration is asynchronous, so the serviceRegistered and serviceRegistrationFailed events must be observed to ensure the service has actually been registered.

A registered service can be unregistered, by passing its ServiceHandle to unregisterService().

Before a DNSSDResponder instance can be created, registerImplFactory() must be called to register a DNSSDResponderImplFactory. This is done by calling the initializeDNSSD() function provided by an implementation library (e.g., Bonjour or Avahi).

Member Summary

Member Functions: addRecord, browser, registerImplFactory, registerService, removeRecord, start, stop, unregisterImplFactory, unregisterService, updateRecord

Nested Classes

struct ErrorEventArgs


struct ServiceEventArgs




Options for service registration.


Service is visible on local host only.


Do not allow automatic renaming in case another service with the same name exists.


Service is not visible when browsing, but can be resolved.




Creates a DNSSDResponder.




Destroys the DNSSDResponder.

Member Functions


RecordHandle addRecord(
    ServiceHandle serviceHandle,
    const Record & record

Add a record to a registered service. The name of the record will be the same as the registered service's name.

The record can later be updated or deregistered by passing the RecordHandle returned by this function to updateRecord() or removeRecord().


DNSSDBrowser & browser();

Returns the DNSServiceBrowser, which is used to discover and resolve services and domains.

registerImplFactory static

static void registerImplFactory(
    DNSSDResponderImplFactory & factory

Registers the factory for creating DNSSDResponderImpl objects.

A factory must be registered before the first instance of DNSSDResponder is created.


ServiceHandle registerService(
    const Service & service,
    int options = 0

Registers a service, specified by the given Service object.

Valid option values are defined in the RegistrationOptions enumeration.

Service registration will be asynchronously. When the service has been registered successfully, a serviceRegistered event will be fired. Otherwise, a ServiceRegistrationFailed event will be fired.

Returns a ServiceHandle that can later be used to unregister the service, or to add DNS records to the service.


void removeRecord(
    ServiceHandle serviceHandle,
    RecordHandle & recordHandle

Remove a registered resource record. The record must be a record added to a registered service via addRecord().

The RecordHandle is invalidated.


void start();

Starts the responder.

Must be called before services can be registered or before browsing for domains and services.


void stop();

Stops the responder.

unregisterImplFactory static

static void unregisterImplFactory();

Unregisters the currently registered DNSSDResponderImplFactory.


void unregisterService(
    ServiceHandle & serviceHandle

Unregisters the service specified by serviceHandle.

The ServiceHandle is invalidated.


void updateRecord(
    ServiceHandle serviceHandle,
    RecordHandle recordHandle,
    const Record & record

Update a registered resource record. The record must either be:

  • the primary txt record of a service registered via registerService() (if recordHandle is a null handle), or
  • a record added to a registered service via addRecord().



Poco::BasicEvent < const ServiceEventArgs > serviceRegistered;

Fired after the service has been registered successfully.

If auto-rename has been enabled, the service name may be different from the name originally specified.


Poco::BasicEvent < const ErrorEventArgs > serviceRegistrationFailed;

Fired when service registration fails.

Securely control IoT edge devices from anywhere   Connect a Device