The mDNS module is intended exclusively for developer needs. It provides some terminal commands, but they serve mostly exploratory and test purposes.
Getting Notifications
Any service topology changes are communicated to the higher levels using the EventAdmin with the following events:
To get notified for these events you need to register normal OSGi event handlers.
Registering own Service
In case you need to announce some functionality in the network, you can register your own service. Thus your functionality will be discoverable via mDNS and will be available for the other devices in the network. This can be done by providing all required information in the ServiceInstance object passed to the register method. Since the success of the registration depends on the underlying mDNS implementations and the network, this method is asynchronous and the registration completes with a TOPIC_SERVICE_INSTANCE_ADDED event notification. This method returns and instance of ServiceInstanceRegistration hook object that can be used to verify the state of the service and especially when one wants to stop announcing a given service.
Finding a Service
There are several methods that can be used in order to find some specific service.
Depending on your needs and knowledge, various combinations of these methods can be used to find the service needed by your application.
For example, you can use just the getServiceInstance method, if you are sure the service is already known. You can list the service instances of a given type and manually search for the one you need.
If this approach is not successful, you could initiate a network search for the service in question using some of the browse methods. In addition to the browse methods, event subscriptions will ensure you get further notifications.
Updating Service Information
If the information for a given service is outdated you can use some of the resolve methods. They behave very similarly to the browse methods and event subscriptions will provide further notifications.
These methods can also be used for checking service presence.