Class DnssdService

Definition

Namespace:
Tizen.Network.Nsd
Assembly:
Tizen.Network.Nsd.dll

This class is used for managing the local service registration and its properties using DNS-SD.

C#
Copy
public class DnssdService : INsdService, IDisposable
Inheritance
object
DnssdService
Implements
System.IDisposable

Constructors

View Source

DnssdService(string)

The constructor to create the DnssdService instance that sets the serviceType to a given value.

Declaration
C#
Copy
public DnssdService(string serviceType)
Parameters
Type Name Description
string serviceType

The DNS-SD service type. It is expressed as a type followed by the protocol, separated by a dot (For example, "_ftp._tcp"). It must begin with an underscore followed by 1-15 characters, which may be letters, digits, or hyphens.

Exceptions
Type Condition
System.NotSupportedException

Thrown while setting this property when DNS-SD is not supported.

System.ArgumentException

Thrown when the serviceType is set to null.

Properties

View Source

IP

IP address of the DNS-SD remote service.

Declaration
C#
Copy
public IPAddressInformation IP { get; }
Property Value
Type Description
IPAddressInformation
Remarks

If the remote service has no IPv4 Address, then IPv4Address would contain null and if it has no IPv6 Address, then IPv6Address would contain null. In case of an error, null object will be returned.

View Source

Name

Name of the DNS-SD service.

Declaration
C#
Copy
public string Name { get; set; }
Property Value
Type Description
string
Remarks

Set the name for only an unregistered service created locally. It may be up to 63 bytes. In case of an error, null will be returned during get and exception will be thrown during set.

Exceptions
Type Condition
System.NotSupportedException

Thrown while setting this property when DNS-SD is not supported.

System.ArgumentException

Thrown when the name value is set to null.

System.InvalidOperationException

Thrown while setting this property when any other error occurred.

View Source

Port

Port number of the DNS-SD local or remote service.

Declaration
C#
Copy
public int Port { get; set; }
Property Value
Type Description
int
Remarks

Set the port for only an unregistered service created locally. The default value of the port is 0. In case of an error, -1 will be returned during get and exception will be thrown during set.

Exceptions
Type Condition
System.NotSupportedException

Thrown while setting this property when DNS-SD is not supported.

System.ArgumentException

Thrown if the value of port is set to less than 0 or more than 65535.

System.InvalidOperationException

Thrown while setting this property when any other error occurred.

View Source

Type

Type of the DNS-SD local or remote service.

Declaration
C#
Copy
public string Type { get; }
Property Value
Type Description
string
Remarks

It is expressed as a type followed by the protocol, separated by a dot (For example, "_ftp._tcp"). It must begin with an underscore followed by 1-15 characters, which may be letters, digits, or hyphens. In case of an error, null will be returned.

Methods

View Source

AddTXTRecord(string, string)

Adds the TXT record.

Declaration
C#
Copy
public void AddTXTRecord(string key, string value)
Parameters
Type Name Description
string key

The key of the TXT record. It must be a null-terminated string with 9 characters or fewer excluding null. It is case insensitive.

string value

The value of the TXT record. If null, then "key" will be added with no value. If non-null but the value_length is zero, then "key=" will be added with an empty value.

Remarks

TXT record should be added after registering the local service using RegisterService().

Exceptions
Type Condition
System.NotSupportedException

Thrown when DNS-SD is not supported.

System.ArgumentException

Thrown when the value of the key is null.

System.InvalidOperationException

Thrown when any other error occurred.

View Source

DeregisterService()

Deregisters the DNS-SD local service.

Declaration
C#
Copy
public void DeregisterService()
Remarks

A local service registered using RegisterService() must be passed.

Exceptions
Type Condition
System.InvalidOperationException

Thrown when any other error occurred.

System.NotSupportedException

Thrown when DNS-SD is not supported.

View Source

Dispose()

Disposes the memory allocated to unmanaged resources.

Declaration
C#
Copy
public void Dispose()
View Source

~DnssdService()

Destroys the DnssdService object.

Declaration
C#
Copy
protected ~DnssdService()
View Source

RegisterService()

Registers the DNS-SD local service for publishing.

Declaration
C#
Copy
public void RegisterService()
Exceptions
Type Condition
System.InvalidOperationException

Thrown when any other error occurred.

System.NotSupportedException

Thrown when DNS-SD is not supported.

System.UnauthorizedAccessException

Thrown when the permission is denied.

View Source

RemoveTXTRecord(string)

Removes the TXT record.

Declaration
C#
Copy
public void RemoveTXTRecord(string key)
Parameters
Type Name Description
string key

The key of the TXT record to be removed.

Exceptions
Type Condition
System.NotSupportedException

Thrown when DNS-SD is not supported.

System.ArgumentException

Thrown when the value of the key is null.

System.InvalidOperationException

Thrown when any other error occurred.

Implements

System.IDisposable