Sdílet prostřednictvím


DnssdServiceInstance Class

Definition

Encapsulates an instance of a service that uses DNS Service Discovery (DNS-SD).

Note

Win32 DNS Service Discovery (DNS-SD) APIs are declared in the windns.h header. For example, the Win32 APIs for announcing and discovering services are DnsServiceRegister and DnsServiceBrowse.

public ref class DnssdServiceInstance sealed : IStringable
/// [Windows.Foundation.Metadata.Activatable(Windows.Networking.ServiceDiscovery.Dnssd.IDnssdServiceInstanceFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class DnssdServiceInstance final : IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Networking.ServiceDiscovery.Dnssd.IDnssdServiceInstanceFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class DnssdServiceInstance final : IStringable
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Networking.ServiceDiscovery.Dnssd.IDnssdServiceInstanceFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class DnssdServiceInstance : IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Networking.ServiceDiscovery.Dnssd.IDnssdServiceInstanceFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class DnssdServiceInstance : IStringable
function DnssdServiceInstance(dnssdServiceInstanceName, hostName, port)
Public NotInheritable Class DnssdServiceInstance
Implements IStringable
Inheritance
Object Platform::Object IInspectable DnssdServiceInstance
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

Use this class if you are providing a service that advertises itself to other DNS-SD users, or if you are consuming services advertised via DNS-SD.

If your code attempts to register a service instance with the same name as a previously-registered service, your service will be renamed to avoid a conflict by adding a number in parentheses at the end of the name you specified. For example, if you specified "mygame" and that name was already registered for another service, your service would be renamed to something like, "mygame (2)". When this is done, DnssdRegistrationResult.HasInstanceNameChanged is set to true.

Constructors

DnssdServiceInstance(String, HostName, UInt16)

Creates a new DnssdServiceInstance object with the specified instance name, host name, and port.

Properties

DnssdServiceInstanceName

Gets or sets the DNS-SD service instance name for this DnssdServiceInstance.

HostName

Gets or sets the hostname of the host for this DnssdServiceInstance.

Port

Gets or sets the port number used by this DnssdServiceInstance.

Priority

Gets or sets the priority value to assign to this service instance, as defined in RFC 2782 A DNS RR for specifying the location of services (DNS SRV). Clients use Priority to decide which of several equivalent service instances to attach to.

TextAttributes

Gets the attributes of this service instance, as a list of [name, value] pairs of strings. Attributes can be inspected by service clients to determine additional information about a service instance.

The specific attribute names and values used by a service are determined by the designer of the service. For example, a service instance for a multiplayer game might have attributes describing which game map the instance is using, or the game difficulty level of the instance. Different service instances would be active for different maps or difficulty levels, and a client using the game service could use the attribute values to determine which game server instance to connect to for the player's preferred map or difficulty level.

Weight

Gets or sets the weight value assigned to this service instance, as defined in RFC 2782. Clients use the Weight value to choose between servers with the same Priority value.

Methods

RegisterDatagramSocketAsync(DatagramSocket, NetworkAdapter)

Asynchronously registers a datagram (UDP) socket listener for the service, on a given socket and network adapter.

RegisterDatagramSocketAsync(DatagramSocket)

Asynchronously registers a datagram (UDP) socket listener for the service, on a given socket.

RegisterStreamSocketListenerAsync(StreamSocketListener, NetworkAdapter)

Asynchronously registers a stream (TCP) socket listener for the service, on the given socket and network adapter.

RegisterStreamSocketListenerAsync(StreamSocketListener)

Asynchronously registers a stream (TCP) socket listener for the service, on the given socket.

ToString()

Gets the DNS Server Resource Record (SRV RR) of this service instance, as a string.

See RFC 1034 DOMAIN NAMES - CONCEPTS AND FACILITIES for the format and contents of the DNS SRV RR, and RFC 2782 and RFC 6763 DNS-Based Service Discovery for details about how DNS-SD clients and servers use those records.

Applies to

See also