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

See Also Languages PowerTCP Email Validation for .NET

EndGetHost Event

Dart.PowerTCP.EmailValidation Namespace > Dns Class : EndGetHost Event

Raised when the Dns.BeginGetHost request completes.

[Visual Basic]
<CategoryAttribute("Completion")> <DescriptionAttribute("Raised when the BeginGetHost() request completes")> Public Event EndGetHost() As DnsEventHandler
[C#]
[CategoryAttribute("Completion")] [DescriptionAttribute("Raised when the BeginGetHost() request completes")] public event DnsEventHandler EndGetHost();
[C++]
[CategoryAttribute("Completion")] [DescriptionAttribute("Raised when the BeginGetHost() request completes")] public: __event DnsEventHandler* EndGetHost();
[C++/CLI]
[CategoryAttribute("Completion")] [DescriptionAttribute("Raised when the BeginGetHost() request completes")] public: event DnsEventHandler^ EndGetHost();

Event Data

The event handler receives an argument of type DnsEventArgs containing data related to this event. The following DnsEventArgs properties provide information specific to this event.

PropertyDescription
Exception Gets any exception which occurred during the asynchronous operation.
Host Gets the IPHostEntry object representing the resolved host name or IP address.
Hosts Gets an array of IPHostEntry objects representing the mail server(s) responsible for receiving mail for a given email address.
State Gets the object that was included as part of the associated method call.

Remarks

This event is raised when the asynchronous method call Dns.BeginGetHost completes. A DnsEventArgs object is passed into the event, containing information such as the resolved name or addresses.

If any errors occurred during the asynchronous operation, they would be returned in the DnsEventArgs object, check DnsEventArgs.Exception to check for any exception.

For more information on using events using PowerTCP.NET within the Visual Studio.NET environment, see the topic, Using Events In PowerTCP.

If you are using the Dns component as a reference, you must create a method to handle the event yourself.

This event MUST be implemented if you are using the Dns.BeginGetHost method.

Example

The following example demonstrates using the Dns control to asynchronously resolve a domain name.

[Visual Basic] 

Private Sub AsynchResolveTest()
   Dns1.Server = "206.64.128.5"
   Dns1.BeginGetHost("www.dart.com", Nothing)
End Sub

Private Sub Dns1_EndGetHost(ByVal sender As Object, ByVal e As DnsEventArgs) Handles Dns1.EndGetHost
   ' Check for any exceptions that occurred
   If e.Exception Is Nothing Then
      DisplayResult(e.Host)
   End If
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 AsynchResolveTest()
{
  dns1.Server =
"206.64.128.5";
  dns1.BeginGetHost(
"www.dart.com", null);
}

private void dns1_EndGetHost(object sender, DnsEventArgs e)
{
  
// Check for any exceptions that occurred
  
if(e.Exception == null)
  {
     DisplayResult(e.Host);
  }
}

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.