Resolver¶
Resolver is the static entry-point facade for performing DNS lookups over UDP. It builds no state of its own (it is sealed with a private constructor) and exposes two static methods: a generic Lookup and a convenience MXLookup.
Purpose¶
- Provide the primary caller-facing API for sending a
Requestto a DNS server and obtaining a parsedResponse. - Provide a convenience wrapper for the common case of retrieving and preference-sorting MX records for a domain.
- Own the low-level UDP socket transfer and retry logic used by all lookups.
Context¶
- Namespace:
SAIF.Framework.DNS - Assembly/package:
SAIF.BOF.Framework.DNS(bundled as source into theSAIF.BOF.FrameworkNuGet package)
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| MXLookup | public static MXRecord[] MXLookup(string domain, IPAddress dnsServer) |
Builds an MX/IN request for domain, performs the lookup, and returns matching MX answers sorted ascending by preference (or null if no response). |
| Lookup | public static Response Lookup(Request request, IPAddress dnsServer) |
Serializes request, sends it via UDP to dnsServer on port 53 with retry, and returns the parsed Response. |
Behavioral notes¶
Resolvercannot be instantiated; its constructor is private and the class issealed, consistent with a stateless static utility.MXLookupandLookupboth throwArgumentNullExceptionif any required argument isnull.Lookupcommunicates over UDP to port 53 with up to 2 retries and a 1-second receive timeout per attempt, throwingNoResponseExceptionif no matching reply is received after all attempts.- A UDP reply is only accepted if its stamped 2-byte transaction id matches the outgoing request; otherwise the attempt is treated as unanswered and the retry loop continues.
- Enforces BR-001, BR-005, BR-006, and BR-008.
Constraints and usage notes¶
- Only one
QuestionperRequestis recommended, since many DNS servers do not support multi-question requests*. - Callers should be prepared to catch
NoResponseException(transport failure) andInvalidResponseException(malformed reply) separately, since they signal distinct failure modes.
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.
Sources¶
- SAIF.Framework.DNS\Resolver.cs