Dart.PowerTCP.SslSockets Namespace > Dns Class : EndGetMailHosts Event |
Raised when the BeginGetMailHosts request completes.
[Visual Basic]
<DescriptionAttribute("Raised when the BeginGetMailHosts() request completes")>
<CategoryAttribute("Completion")>
Public Event EndGetMailHosts() As DnsEventHandler
[C#]
[DescriptionAttribute("Raised when the BeginGetMailHosts() request completes")]
[CategoryAttribute("Completion")]
public event DnsEventHandler EndGetMailHosts();
[C++]
[DescriptionAttribute("Raised when the BeginGetMailHosts() request completes")]
[CategoryAttribute("Completion")]
public: __event DnsEventHandler* EndGetMailHosts();
[C++/CLI]
[DescriptionAttribute("Raised when the BeginGetMailHosts() request completes")]
[CategoryAttribute("Completion")]
public:
event DnsEventHandler^ EndGetMailHosts();
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.
Property | Description |
---|---|
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. |
This event is raised when the asynchronous method call BeginGetMailHosts completes. A DnsEventArgs object is passed into the event, containing information such as the resolved mail server responsible for the email address.
If any errors occurred during the asynchronous operation, they would be returned in the DnsEventArgs object, check 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 BeginGetHost method.
The following example demonstrates asynchronously resolving an email address.
[Visual Basic]
Private Sub AsynchResolveTest()
Dns1.Server = "206.64.128.5"
Dns1.BeginGetMailHosts("gates@microsoft.com", Nothing)
End Sub
Private Sub Dns1_EndGetMailHosts(ByVal sender As Object, ByVal e As DnsEventArgs) Handles Dns1.EndGetMailHosts
' Check for any exceptions that occurred
If e.Exception Is Nothing Then
' Iterate through all IPHostEntry objects
Dim result As System.Net.IPHostEntry
For Each result In e.Hosts
DisplayResult(result)
Next
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.BeginGetMailHosts("gates@microsoft.com", null);
}
private void dns1_EndGetMailHosts(object
sender, DnsEventArgs e)
{
// Check for any exceptions that occurred
if(e.Exception == null)
{
// Iterate through all IPHostEntry objects
foreach(System.Net.IPHostEntry result in
e.Hosts)
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 Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Send comments on this topic.
Documentation version 1.1.2.0.
© 2008 Dart Communications. All rights reserved.