Class ServiceDiscovery
DNS based Service Discovery is a way of using standard DNS programming interfaces, servers, and packet formats to browse the network for services.
Implements
Inherited Members
Namespace: Makaretu.Dns
Assembly: Makaretu.Dns.Multicast.dll
Syntax
public class ServiceDiscovery : IDisposable
Constructors
| Improve this Doc View SourceServiceDiscovery()
Creates a new instance of the ServiceDiscovery class.
Declaration
public ServiceDiscovery()
ServiceDiscovery(MulticastService)
Creates a new instance of the ServiceDiscovery class with the specified MulticastService.
Declaration
public ServiceDiscovery(MulticastService mdns)
Parameters
Type | Name | Description |
---|---|---|
MulticastService | mdns | The underlaying MulticastService to use. |
Fields
| Improve this Doc View SourceServiceName
The service discovery service name.
Declaration
public static readonly DomainName ServiceName
Field Value
Type | Description |
---|---|
DomainName | The service name used to enumerate other services. |
Properties
| Improve this Doc View SourceAnswersContainsAdditionalRecords
Add the additional records into the answers.
Declaration
public bool AnswersContainsAdditionalRecords { get; set; }
Property Value
Type | Description |
---|---|
Boolean | Defaults to false. |
Remarks
Some malformed systems, such as js-ipfs and go-ipfs, only examine the Answers and not the AdditionalRecords. Setting this to true, will move the additional records into the answers.
This never done for DNS-SD answers.
Mdns
Gets the multicasting service.
Declaration
public MulticastService Mdns { get; }
Property Value
Type | Description |
---|---|
MulticastService | Is used to send and recieve multicast Message. |
NameServer
Gets the name server.
Declaration
public NameServer NameServer { get; }
Property Value
Type | Description |
---|---|
NameServer | Is used to answer questions. |
Methods
| Improve this Doc View SourceAdvertise(ServiceProfile)
Advertise a service profile.
Declaration
public void Advertise(ServiceProfile service)
Parameters
Type | Name | Description |
---|---|---|
ServiceProfile | service | The service profile. |
Remarks
Any queries for the service or service instance will be answered with information from the profile.
Besides adding the profile's resource records to the Catalog PTR records are created to support DNS-SD and reverse address mapping (DNS address lookup).
Announce(ServiceProfile)
Sends an unsolicited MDNS response describing the service profile.
Declaration
public void Announce(ServiceProfile profile)
Parameters
Type | Name | Description |
---|---|---|
ServiceProfile | profile | The profile to describe. |
Remarks
Sends a MDNS response Message containing the pointer
and resource records of the profile
.
To provide increased robustness against packet loss, two unsolicited responses are sent one second apart.
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing |
QueryAllServices()
Asks other MDNS services to send their service names.
Declaration
public void QueryAllServices()
Remarks
When an answer is received the ServiceDiscovered event is raised.
QueryServiceInstances(DomainName)
Asks instances of the specified service to send details.
Declaration
public void QueryServiceInstances(DomainName service)
Parameters
Type | Name | Description |
---|---|---|
DomainName | service | The service name to query. Typically of the form "_service._tcp". |
Remarks
When an answer is received the ServiceInstanceDiscovered event is raised.
See Also
| Improve this Doc View SourceQueryServiceInstances(DomainName, String)
Asks instances of the specified service with the subtype to send details.
Declaration
public void QueryServiceInstances(DomainName service, string subtype)
Parameters
Type | Name | Description |
---|---|---|
DomainName | service | The service name to query. Typically of the form "_service._tcp". |
String | subtype | The feature that is needed. |
Remarks
When an answer is received the ServiceInstanceDiscovered event is raised.
See Also
| Improve this Doc View SourceQueryUnicastAllServices()
Asks other MDNS services to send their service names; accepts unicast and/or broadcast answers.
Declaration
public void QueryUnicastAllServices()
Remarks
When an answer is received the ServiceDiscovered event is raised.
QueryUnicastServiceInstances(DomainName)
Asks instances of the specified service to send details. accepts unicast and/or broadcast answers.
Declaration
public void QueryUnicastServiceInstances(DomainName service)
Parameters
Type | Name | Description |
---|---|---|
DomainName | service | The service name to query. Typically of the form "_service._tcp". |
Remarks
When an answer is received the ServiceInstanceDiscovered event is raised.
See Also
| Improve this Doc View SourceUnadvertise()
Sends a goodbye message for each anounced service.
Declaration
public void Unadvertise()
Unadvertise(ServiceProfile)
Sends a goodbye message for the provided profile and removes its pointer from the name sever.
Declaration
public void Unadvertise(ServiceProfile profile)
Parameters
Type | Name | Description |
---|---|---|
ServiceProfile | profile | The profile to send a goodbye message for. |
Events
| Improve this Doc View SourceServiceDiscovered
Raised when a DNS-SD response is received.
Declaration
public event EventHandler<DomainName> ServiceDiscovered
Event Type
Type | Description |
---|---|
EventHandler<DomainName> | Contains the service name. |
Remarks
ServiceDiscovery passively monitors the network for any answers to a DNS-SD query. When an anwser is received this event is raised.
Use QueryAllServices() to initiate a DNS-SD question.
ServiceInstanceDiscovered
Raised when a servive instance is discovered.
Declaration
public event EventHandler<ServiceInstanceDiscoveryEventArgs> ServiceInstanceDiscovered
Event Type
Type | Description |
---|---|
EventHandler<ServiceInstanceDiscoveryEventArgs> | Contains the service instance name. |
Remarks
ServiceDiscovery passively monitors the network for any answers. When an answer containing a PTR to a service instance is received this event is raised.
ServiceInstanceShutdown
Raised when a servive instance is shutting down.
Declaration
public event EventHandler<ServiceInstanceShutdownEventArgs> ServiceInstanceShutdown
Event Type
Type | Description |
---|---|
EventHandler<ServiceInstanceShutdownEventArgs> | Contains the service instance name. |
Remarks
ServiceDiscovery passively monitors the network for any answers. When an answer containing a PTR to a service instance with a TTL of zero is received this event is raised.