• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Class DnsClient

A minimal DNS client for TXT record lookup (RFC 1035). Supports UDP transport with TCP fallback for truncated responses, configurable query timeout, and multiple nameservers.

Inheritance
object
DnsClient
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
Namespace: DRIT.Mail.Rfc.Net
Assembly: DRIT.Mail.dll
Syntax
public sealed class DnsClient

Constructors

View Source

DnsClient()

Initializes a new instance of the DnsClient class with a default 5-second query timeout.

Declaration
public DnsClient()
View Source

DnsClient(TimeSpan)

Initializes a new instance of the DnsClient class with the specified query timeout.

Declaration
public DnsClient(TimeSpan queryTimeout)
Parameters
Type Name Description
TimeSpan queryTimeout

The timeout for each DNS query attempt.

Methods

View Source

ResolveTxtRecords(string)

Resolves TXT records for the given domain name using the system's configured DNS nameservers.

Declaration
public IReadOnlyList<string> ResolveTxtRecords(string name)
Parameters
Type Name Description
string name

The domain name to query (e.g., "selector._domainkey.example.com").

Returns
Type Description
IReadOnlyList<string>

A list of TXT record values. Each entry is the concatenated character-string value of one TXT record in the answer section. Returns an empty list if no TXT records are found.

Exceptions
Type Condition
ArgumentNullException

Thrown if name is null.

DnsException

Thrown if the query fails on all nameservers (timeout, network error, or server failure).

View Source

ResolveTxtRecords(string, params string[])

Resolves TXT records for the given domain name using the specified nameservers. Nameservers are tried in order; the first to return a definitive answer is used.

Declaration
public IReadOnlyList<string> ResolveTxtRecords(string name, params string[] nameservers)
Parameters
Type Name Description
string name

The domain name to query.

string[] nameservers

IPv4 or IPv6 addresses of DNS nameservers to query, in preference order.

Returns
Type Description
IReadOnlyList<string>

A list of TXT record values. Returns an empty list if the name exists but has no TXT records, or if the name does not exist (NXDOMAIN).

Exceptions
Type Condition
ArgumentNullException

Thrown if name or nameservers is null.

ArgumentException

Thrown if nameservers is empty.

DnsException

Thrown if all nameservers fail to respond.

  • View Source
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX