Version: 1.1.1.0
Create multi-threaded servers and powerful Internet applications in .NET.

Dns .NET Component

Use the Dns component to integrate domain name resolution functionality into any .NET application, allowing your application to easily resolve domain names, host addresses, and email addresses. Features include:

  • The Dns component bypasses Winsock system services, so you can query ANY Domain Name Server on the Internet.
  • Easy-to-use GetHost method resolves a host name to a dot address (forward lookup) and resolves a dot address to a host name (reverse lookup).
  • GetMailHosts method resolves an email address to the mail server(s) responsible for the email address. Not supported in the .NET Framework!
  • Resolve names synchronously or asynchronously.
  • Trace event exposes the underlying TCP communication.
  • Design-time editor assists in protocol testing.
  • C# and VB.NET sample projects included.
  • Includes a royalty-free license!

Looking forĀ the ActiveX version of this component?

Interface

Public Constructors
Dns Overloaded. Initialize a new instance of the Dns class.
Public Properties
Client Gets or sets the client hostname or address when a specific interface binding is desired.
ClientPort Gets or sets a string used to restrict the local data port to a value or range of values.
DoEvents Gets or sets a value that controls the processing of events during blocking method calls.
Editor In Visual Studio.NET, displays an interactive form to use to test real time protocol operations.
Server Gets or sets the DNS server hostname or address.
ServerPort Gets or sets the port to use for communicating with the DNS server.
SynchronizingObject Set this object to automatically control thread marshalling between worker threads and the main UI thread.
Timeout Specifies the maximum number of milliseconds to wait for responses to commands or time between data buffer transfers.
Public Methods
Abort Stops the name resolve operation.
BeginGetHost Asynchronously resolve a host name to a dot address or a dot address to a host name.
GetHost Resolve a host name to a dot address or a dot address to a host name.
GetMailHosts Get the mail server (or servers) responsible for receiving mail for a given email address.
Public Events
Trace Raised when data has been sent/received.

Code Example

How easy is the Dns component to use? The following VB.NET component demonstrates resolving an email address to the mail server responsible for that email address.

VB.NET Example
' Set the DNS server to use.
Dns1.Server = "MyDnsServer"

' Resolve the email address.
Try
   Dim results = Dns1.GetHost("test@dart.com")

   'Iterate through all IPHostEntry objects
   Dim result As System.Net.IPHostEntry
   For Each result In results

      ' Display host name
      Debug.WriteLine("Host name: " + result.HostName)

      ' Display addresses, if any
      Dim add As System.Net.IPAddress
      For Each add In result.AddressList
         Debug.WriteLine("Address: " + add.ToString())
      Next

      ' Display aliases, if any
      Dim s As String
      For Each s In result.Aliases
         Debug.WriteLine("Aliases: " + s)
      Next
   Next
Catch ex as Exception
   Debug.WriteLine("Name cannot be resolved. Error: " + ex.Message)
End Try