Class DnsClient
Client to a unicast DNS server.
Inherited Members
Namespace: Makaretu.Dns
Assembly: Makaretu.Dns.Unicast.dll
Syntax
public class DnsClient : DnsClientBase, IDnsClient, IDisposable, IResolver
Remarks
Sends and receives DNS queries and answers to unicast DNS servers.
Properties
| Improve this Doc View SourceServers
The DNS servers to communication with.
Declaration
public IEnumerable<IPAddress> Servers { get; set; }
Property Value
Type | Description |
---|---|
IEnumerable<IPAddress> | A sequence of IP addresses. When null GetServers() is used. The default is null. |
TimeoutTcp
Time to wait for a DNS TCP response.
Declaration
public TimeSpan TimeoutTcp { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan | The default is 4 seconds. |
TimeoutUdp
Time to wait for a DNS UDP response.
Declaration
public TimeSpan TimeoutUdp { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan | The default is 4 seconds. |
Methods
| Improve this Doc View SourceAvailableServers()
Get the DNS servers that can be communicated with.
Declaration
public IEnumerable<IPAddress> AvailableServers()
Returns
Type | Description |
---|---|
IEnumerable<IPAddress> | A sequence of IP addresses for the DNS servers. |
Remarks
Only servers with an AddressFamily supported by the OS is returned.
GetServers()
Get the DNS servers.
Declaration
public IEnumerable<IPAddress> GetServers()
Returns
Type | Description |
---|---|
IEnumerable<IPAddress> | A sequence of IP addresses for the DNS servers. |
QueryAsync(Message, CancellationToken)
Send a DNS query with the specified message.
Declaration
public override Task<Message> QueryAsync(Message request, CancellationToken cancel = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Message | request | |
CancellationToken | cancel | Is used to stop the task. When cancelled, the TaskCanceledException is raised. |
Returns
Type | Description |
---|---|
Task<Message> | A task that represents the asynchronous operation. The task's value contains the response Message. |
Overrides
Remarks
The request
is sent with UDP. If no response is
received (or is truncated) in TimeoutUdp, then it is resent via TCP.
Some home routers have issues with IPv6, so IPv4 servers are tried first.
Exceptions
Type | Condition |
---|---|
IOException | When the DNS server returns error status or no response. |