Class DnsClientBase
Base class for a DNS client.
Inherited Members
Namespace: Makaretu.Dns
Assembly: Makaretu.Dns.Unicast.dll
Syntax
public abstract class DnsClientBase : IDnsClient, IDisposable, IResolver
Remarks
Sends and receives DNS queries and answers to unicast DNS servers.
Properties
| Improve this Doc View SourceThrowResponseError
Determines if an exception is thrown when a response contains an error.
Declaration
public bool ThrowResponseError { get; set; }
Property Value
Type | Description |
---|---|
Boolean | Defaults to true. |
Remarks
When set, an exception is thrown if the response's Status is not NoError or is considered invalid for the request.
Methods
| Improve this Doc View SourceDispose()
Declaration
public void Dispose()
Dispose(Boolean)
Dispose the client.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | true if managed resources should be disposed. |
NextQueryId()
Get the next ID for a query message.
Declaration
public ushort NextQueryId()
Returns
Type | Description |
---|---|
UInt16 | The next Id |
Remarks
This is thread safe.
QueryAsync(DomainName, DnsType, CancellationToken)
Send a DNS query with the specified name and resource record type.
Declaration
public Task<Message> QueryAsync(DomainName name, DnsType rtype, CancellationToken cancel = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
DomainName | name | A domain name. |
DnsType | rtype | A resource record type. |
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. |
Remarks
Creates a query Message and then calls QueryAsync(Message, CancellationToken).
QueryAsync(Message, CancellationToken)
Send a DNS query with the specified message.
Declaration
public abstract 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. |
Remarks
The request
is sent with UDP. If no response is
received (or is truncated) in Timeout, 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. |
ResolveAsync(DomainName, CancellationToken)
Get the IP addresses for the specified name.
Declaration
public Task<IEnumerable<IPAddress>> ResolveAsync(DomainName name, CancellationToken cancel = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
DomainName | name | A domain name to resolve. |
CancellationToken | cancel | Is used to stop the task. When cancelled, the TaskCanceledException is raised. |
Returns
Type | Description |
---|---|
Task<IEnumerable<IPAddress>> | A task that represents the asynchronous operation. The task's value
contains the IPAddress sequence for the |
ResolveAsync(Message, CancellationToken)
Another name for QueryAsync(Message, CancellationToken).
Declaration
public Task<Message> ResolveAsync(Message request, CancellationToken cancel = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Message | request | |
CancellationToken | cancel |
Returns
Type | Description |
---|---|
Task<Message> |
ResolveAsync(IPAddress, CancellationToken)
Reverse query for an IP address.
Declaration
public Task<DomainName> ResolveAsync(IPAddress address, CancellationToken cancel = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IPAddress | address | An IP address with an AddressFamily of InterNetwork or InterNetworkV6. |
CancellationToken | cancel | Is used to stop the task. When cancelled, the TaskCanceledException is raised. |
Returns
Type | Description |
---|---|
Task<DomainName> | A task that represents the asynchronous operation. The task's value
is the domain name of |
Remarks
Performs a reverse lookup with a PTR. The
response contains the name(s) of the address
.
SecureQueryAsync(DomainName, DnsType, CancellationToken)
Send a DNSSEC query with the specified name and resource record type.
Declaration
public Task<Message> SecureQueryAsync(DomainName name, DnsType rtype, CancellationToken cancel = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
DomainName | name | A domain name. |
DnsType | rtype | A resource record type. |
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. |
Remarks
Creates a secure query Message and then calls QueryAsync(Message, CancellationToken).