Exemple #1
0
        /// <summary>Ends an asynchronous request for DNS information.</summary>
        /// <returns>An array of type <see cref="T:System.Net.IPAddress" /> that holds the IP addresses for the host specified by the <paramref name="hostNameOrAddress" /> parameter of <see cref="M:System.Net.Dns.BeginGetHostAddresses(System.String,System.AsyncCallback,System.Object)" />.</returns>
        /// <param name="asyncResult">An <see cref="T:System.IAsyncResult" /> instance returned by a call to the <see cref="M:System.Net.Dns.BeginGetHostAddresses(System.String,System.AsyncCallback,System.Object)" /> method.</param>
        public static IPAddress[] EndGetHostAddresses(IAsyncResult asyncResult)
        {
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }
            AsyncResult asyncResult2 = (AsyncResult)asyncResult;

            Dns.GetHostAddressesCallback getHostAddressesCallback = (Dns.GetHostAddressesCallback)asyncResult2.AsyncDelegate;
            return(getHostAddressesCallback.EndInvoke(asyncResult));
        }
Exemple #2
0
 /// <summary>Asynchronously returns the Internet Protocol (IP) addresses for the specified host.</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="state">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 BeginGetHostAddresses(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.GetHostAddressesCallback getHostAddressesCallback = new Dns.GetHostAddressesCallback(Dns.GetHostAddresses);
     return(getHostAddressesCallback.BeginInvoke(hostNameOrAddress, requestCallback, stateObject));
 }