Show / Hide Table of Contents

Class DnsClient

Client to a unicast DNS server.

Inheritance
Object
DnsClientBase
DnsClient
Implements
IDnsClient
IDisposable
IResolver
Inherited Members
DnsClientBase.ThrowResponseError
DnsClientBase.NextQueryId()
DnsClientBase.ResolveAsync(DomainName, CancellationToken)
DnsClientBase.QueryAsync(DomainName, DnsType, CancellationToken)
DnsClientBase.SecureQueryAsync(DomainName, DnsType, CancellationToken)
DnsClientBase.ResolveAsync(IPAddress, CancellationToken)
DnsClientBase.Dispose()
DnsClientBase.Dispose(Boolean)
DnsClientBase.ResolveAsync(Message, CancellationToken)
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
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 Source

Servers

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

AvailableServers()

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.

| Improve this Doc View Source

GetServers()

Get the DNS servers.

Declaration
public IEnumerable<IPAddress> GetServers()
Returns
Type Description
IEnumerable<IPAddress>

A sequence of IP addresses for the DNS servers.

| Improve this Doc View Source

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

A Message containing a Question.

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
DnsClientBase.QueryAsync(Message, CancellationToken)
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.

Implements

IDnsClient
System.IDisposable
IResolver
  • Improve this Doc
  • View Source
Back to top Generated by DocFX