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;
            GetHostAddressesCallback getHostAddressesCallback = (GetHostAddressesCallback)asyncResult2.AsyncDelegate;

            return(getHostAddressesCallback.EndInvoke(asyncResult));
        }
Exemple #2
0
        public static IAsyncResult BeginGetHostAddresses(string hostName,
                                                         AsyncCallback requestCallback, object stateObject)
        {
            if (hostName == null)
            {
                throw new ArgumentNullException("hostName");
            }

            GetHostAddressesCallback c = new GetHostAddressesCallback(GetHostAddresses);

            return(c.BeginInvoke(hostName, requestCallback, stateObject));
        }
Exemple #3
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");
            }
            GetHostAddressesCallback getHostAddressesCallback = GetHostAddresses;

            return(getHostAddressesCallback.BeginInvoke(hostNameOrAddress, requestCallback, stateObject));
        }
Exemple #4
0
		public static IAsyncResult BeginGetHostAddresses (string hostNameOrAddress,
			AsyncCallback requestCallback, object state)
		{
			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");

			GetHostAddressesCallback c = new GetHostAddressesCallback (GetHostAddresses);
			return c.BeginInvoke (hostNameOrAddress, requestCallback, state);
		}
Exemple #5
0
        public static IPAddress [] EndGetHostAddresses(IAsyncResult asyncResult)
        {
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }

            if (use_mono_dns)
            {
                IPHostEntry entry = EndAsyncCall(asyncResult as DnsAsyncResult);
                if (entry == null)
                {
                    return(null);
                }
                return(entry.AddressList);
            }

            AsyncResult async           = (AsyncResult)asyncResult;
            GetHostAddressesCallback cb = (GetHostAddressesCallback)async.AsyncDelegate;

            return(cb.EndInvoke(asyncResult));
        }
Exemple #6
0
        public static IAsyncResult BeginGetHostAddresses(string hostNameOrAddress, AsyncCallback requestCallback, object state)
        {
            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");
            }

#if !MOBILE
            if (use_mono_dns)
            {
                return(BeginAsyncCallAddresses(hostNameOrAddress, requestCallback, state));
            }
#endif

            GetHostAddressesCallback c = new GetHostAddressesCallback(GetHostAddresses);
            return(c.BeginInvoke(hostNameOrAddress, requestCallback, state));
        }