/// <summary>Asynchronously resolves a host name or IP address to an <see cref="T:System.Net.IPHostEntry" /> instance.</summary> /// <returns>An <see cref="T:System.IAsyncResult" /> instance that references the asynchronous request.</returns> /// <param name="hostNameOrAddress">The host name or IP address to resolve.</param> /// <param name="requestCallback">An <see cref="T:System.AsyncCallback" /> delegate that references the method to invoke when the operation is complete. </param> /// <param name="stateObject">A user-defined object that contains information about the operation. This object is passed to the <paramref name="requestCallback" /> delegate when the operation is complete.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="hostNameOrAddress" /> is null. </exception> /// <exception cref="T:System.ArgumentOutOfRangeException">The length of <paramref name="hostNameOrAddress" /> is greater than 126 characters. </exception> /// <exception cref="T:System.Net.Sockets.SocketException">An error is encountered when resolving <paramref name="hostNameOrAddress" />. </exception> /// <exception cref="T:System.ArgumentException"> /// <paramref name="hostNameOrAddress" /> is an invalid IP address.</exception> public static IAsyncResult BeginGetHostEntry(string hostNameOrAddress, AsyncCallback requestCallback, object stateObject) { if (hostNameOrAddress == null) { throw new ArgumentNullException("hostName"); } if (hostNameOrAddress == "0.0.0.0" || hostNameOrAddress == "::0") { throw new ArgumentException("Addresses 0.0.0.0 (IPv4) and ::0 (IPv6) are unspecified addresses. You cannot use them as target address.", "hostNameOrAddress"); } Dns.GetHostEntryNameCallback getHostEntryNameCallback = new Dns.GetHostEntryNameCallback(Dns.GetHostEntry); return(getHostEntryNameCallback.BeginInvoke(hostNameOrAddress, requestCallback, stateObject)); }