See Also

Dns Class  | Dns Members

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista

Language

Visual Basic

C#

C++

C++/CLI

Show All

host
The host name or dot address to resolve.
See Also Languages PowerTCP Email Validation for .NET

GetHost Method

Dart.PowerTCP.EmailValidation Namespace > Dns Class : GetHost Method

Resolve a host name to a dot address or a dot address to a host name.

[Visual Basic]
<DescriptionAttribute("Perform a synchronous name or IP address resolution.")> Public Function GetHost( _    ByVal host As String _ ) As IPHostEntry
[C#]
[DescriptionAttribute("Perform a synchronous name or IP address resolution.")] public IPHostEntry GetHost(    string host );
[C++]
[DescriptionAttribute("Perform a synchronous name or IP address resolution.")] public: IPHostEntry* GetHost(    string* host )
[C++/CLI]
[DescriptionAttribute("Perform a synchronous name or IP address resolution.")] public: IPHostEntry^ GetHost(    String^ host )

Parameters

host
The host name or dot address to resolve.

Return Type

A System.Net.IPHostEntry object representing the host address.

Exceptions

ExceptionDescription
SocketExceptionNo DNS server was specified.

Remarks

This method provides both forward lookup (resolve a host name to an address) and reverse lookup (resolve an address to a host name).

When host is a DNS-style host name associated with multiple IP addresses, only the first IP address that resolves to that host name is returned.

To resolve an email address, use Dns.GetMailHosts. To resolve a host name or a dot address asynchronously, use Dns.BeginGetHost.

Example

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);
}
                

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista

See Also

Dns Class  | Dns Members


Send comments on this topic.

Documentation version 1.0.3.0.

© 2008 Dart Communications.  All rights reserved.