| Dart.PowerTCP.EmailValidation Namespace > Dns Class : Servers Property | 
Gets or sets a prioritized list of DNS servers.
[Visual Basic]
<BrowsableAttribute(False)>
Public ReadOnly Property Servers As StringCollection[C#]
[BrowsableAttribute(false)]
public StringCollection Servers {get;}[C++]
[BrowsableAttribute(false)]
public: __property StringCollection* get_Servers();[C++/CLI]
[BrowsableAttribute(false)]
public:
property StringCollection^ Servers {
   StringCollection^ get();
}A StringCollection representing the DNS servers to use for resolving.
By default, the component will attempt to ascertain the DNS server(s) used by the system, and populate Servers appropriately.
If the developer does not want a system's default DNS server(s) to be used by the component, the collection should be cleared and added to in code.
Used to identify the DNS resource by either hostname (that is resolved by DNS) or dot address (of the form 11.22.33.44). The object always checks this property, so you can change it at any time and subsequent method calls will automatically communicate with the correct server.
By default, the component will use the port specified in Dns.ServerPort. To specify a non-standard port, use the notation, "Address:Port". For example, "1921.68.0.1:8052".
If Dns.Retries is a positive value, the component will attempt each server in Servers, then, for each retry, again attempt every server in the collection.
If Dns.RotateServers is false, the component will always start with the first listed server when attempting new lookups. If Dns.RotateServers is true, new lookups will use the next listed server.
The following example demonstrates using the Dns control to resolve a domain name.
[Visual Basic]
Private Sub ResolveTest()
   Dns1.Servers.Add("206.64.128.5") 'Adds this server to list of DNS servers
   Dns1.RotateServers = True 'Will always try next server in Dns1.Servers
   Dns1.Retries = 2 'On failures, try an additional two times
   Dns1.RetryInterval = 0 'Do not wait between retries
   Dim result As System.Net.IPHostEntry = Dns1.GetHost("www.dart.com")
   DisplayResult(result)
End Sub
Private Sub DisplayResult(ByVal result As System.Net.IPHostEntry)
   ' 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
End Sub
[C#]
private void ResolveTest()
{
  dns1.Servers.Add("206.64.128.5"); 'Adds this server to list of
DNS servers
  dns1.RotateServers = true; 'Will always try next server in Dns1.Servers
  dns1.Retries = 2; 'On failures, try an additional two times
  dns1.RetryInterval = 0; 'Do not wait between retries
  System.Net.IPHostEntry result = dns1.GetHost("www.dart.com");
  DisplayResult(result);
}
private void DisplayResult(System.Net.IPHostEntry result)
{
  // Display host name
  Debug.WriteLine("Host name: " + result.HostName);
  // Display addresses, if any
  foreach(System.Net.IPAddress add in result.AddressList)
     Debug.WriteLine("Address: " + add.ToString());
  // Display aliases, if any
  foreach(string s in result.Aliases)
     Debug.WriteLine("Aliases: " + s);
}
                Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista
Send comments on this topic.
Documentation version 1.0.3.0.
© 2008 Dart Communications. All rights reserved.