Network Service Discovery
You can use 2 different protocols to perform network service discoveries to announce local services and search for remote services on a network: DNS-SD (DNS Service Discovery) and SSDP (Simple Service Discovery Protocol).
The main features of the Tizen.Network.Nsd namespace include:
Managing local services
Registering a local service announces it over the network, allowing other devices to find and use it. You can create and register local services through the Tizen.Network.Nsd.DnssdService and Tizen.Network.Nsd.SsdpService classes, which both implement the Tizen.Network.Nsd.INsdService interface:
- For the DNS-SD services, you can retrieve service details, such as name, type, port number and IP address, through related properties. You can also add a text record after registering the service, and set the key and value of the record. To remove a record, use its key.
- For the SSDP services, you can retrieve service details, such as name, target, and URL.
Discovering remote services
You can search for remote services on the network through the Tizen.Network.Nsd.DnssdBrowser and Tizen.Network.Nsd.SsdpBrowser classes, which both implement the Tizen.Network.Nsd.INsdBrowser interface. You can also receive notifications when a service is found by registering an event handler for the
ServiceFoundevent of the applicable class.
To enable your application to use the network service discovery functionality:
To use the Tizen.Network.Nsd namespace, the application has to request permission by adding the following privilege to the
<privileges> <privilege>http://tizen.org/privilege/internet</privilege> </privileges>
To make your application visible in Tizen Store only for devices that support the DNS-SD and SSDP protocols, the application must specify the following features in the
<feature name="http://tizen.org/feature/network.service_discovery.dnssd"/> <feature name="http://tizen.org/feature/network.service_discovery.ssdp"/>
To use the methods and properties of the Tizen.Network.Nsd namespace, include it in your application:C#Copy
Registering Local Services
To register and deregister a local DNS-SD service:
Register a service by creating a new instance of the Tizen.Network.Nsd.DnssdService class and using its
/// Register service INsdService service = new DnssdService("_http._tcp"); DnssdService dnssdService = (DnssdService)service; dnssdService.RegisterService();
Deregister the service by using the
Tizen.Network.Nsd.DnssdServiceclass instance is no longer needed, destroy it with the
/// Deregister service dnssdService.DeregisterService(); dnssdService.Dispose();
Discovering Remote Services
To discover remote DNS-SD services:
Start discovery by creating a new instance of the Tizen.Network.Nsd.DnssdBrowser class and using its
/// Start discovery INsdBrowser browser = new DnssdBrowser("_http._tcp"); DnssdBrowser dnssdBrowser = (DnssdBrowser)browser; dnssdBrowser.StartDiscovery();
When you have found the services you need, stop discovery by using the
Tizen.Network.Nsd.DnssdBrowserclass instance is no longer needed, destroy it with the
/// Stop discovery dnssdBrowser.StopDiscovery(); dnssdBrowser.Dispose();
- Tizen 4.0 and Higher