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; dnssdResponder.start(): ... 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.
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).
Options for service registration.
REG_LOCAL_ONLY = 0x01
Service is visible on local host only.
REG_NO_AUTORENAME = 0x02
Do not allow automatic renaming in case another service with the same name exists.
REG_NON_BROWSABLE = 0x04
Service is not visible when browsing, but can be resolved.
Creates a DNSSDResponder.
Destroys the DNSSDResponder.
Add a record to a registered service. The name of the record will be the same as the registered service's name.
DNSSDBrowser & browser();
Returns the DNSServiceBrowser, which is used to discover and resolve services and domains.
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.
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.
Remove a registered resource record. The record must be a record added to a registered service via addRecord().
The RecordHandle is invalidated.
Starts the responder.
Must be called before services can be registered or before browsing for domains and services.
Stops the responder.
static void unregisterImplFactory();
Unregisters the currently registered DNSSDResponderImplFactory.
ServiceHandle & serviceHandle
Unregisters the service specified by serviceHandle.
The ServiceHandle is invalidated.
Update a registered resource record. The record must either be:
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.
Fired when service registration fails.