Пример #1
0
        public static IAsyncResult BeginGetHostEntry(string hostNameOrAddress, AsyncCallback requestCallback, object stateObject)
        {
#if FEATURE_NO_BSD_SOCKETS
            throw new PlatformNotSupportedException("System.Net.Dns:GetHostEntry is not supported on this platform.");
#else
            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(BeginAsyncCall(hostNameOrAddress, requestCallback, stateObject));
            }
#endif

            GetHostEntryNameCallback c = new GetHostEntryNameCallback(GetHostEntry);
            return(c.BeginInvoke(hostNameOrAddress, requestCallback, stateObject));
#endif // FEATURE_NO_BSD_SOCKETS
        }
Пример #2
0
        public static IAsyncResult BeginGetHostEntry(string hostNameOrAddress,
                                                     AsyncCallback requestCallback, object stateObject)
        {
            if (hostNameOrAddress == null)
            {
                throw new ArgumentNullException("hostNameOrAddress");
            }

            GetHostEntryNameCallback c = new GetHostEntryNameCallback(GetHostEntry);

            return(c.BeginInvoke(hostNameOrAddress, requestCallback, stateObject));
        }
Пример #3
0
        /// <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");
            }
            GetHostEntryNameCallback getHostEntryNameCallback = GetHostEntry;

            return(getHostEntryNameCallback.BeginInvoke(hostNameOrAddress, requestCallback, stateObject));
        }
Пример #4
0
        public static IPHostEntry EndGetHostEntry(IAsyncResult asyncResult)
        {
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }
            AsyncResult async = (AsyncResult)asyncResult;

            if (async.AsyncDelegate is GetHostEntryIPCallback)
            {
                return(((GetHostEntryIPCallback)async.AsyncDelegate).EndInvoke(asyncResult));
            }
            GetHostEntryNameCallback cb = (GetHostEntryNameCallback)async.AsyncDelegate;

            return(cb.EndInvoke(asyncResult));
        }
Пример #5
0
        public static IPHostEntry EndGetHostEntry(IAsyncResult asyncResult)
        {
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }

#if !MOBILE
            if (use_mono_dns)
            {
                return(EndAsyncCall(asyncResult as DnsAsyncResult));
            }
#endif

            AsyncResult async = (AsyncResult)asyncResult;
            if (async.AsyncDelegate is GetHostEntryIPCallback)
            {
                return(((GetHostEntryIPCallback)async.AsyncDelegate).EndInvoke(asyncResult));
            }
            GetHostEntryNameCallback cb = (GetHostEntryNameCallback)async.AsyncDelegate;
            return(cb.EndInvoke(asyncResult));
        }
Пример #6
0
        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");
            }

#if !MOBILE
            if (use_mono_dns)
            {
                return(BeginAsyncCall(hostNameOrAddress, requestCallback, stateObject));
            }
#endif

            GetHostEntryNameCallback c = new GetHostEntryNameCallback(GetHostEntry);
            return(c.BeginInvoke(hostNameOrAddress, requestCallback, stateObject));
        }
Пример #7
0
		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");

			if (use_mono_dns)
				return BeginAsyncCall (hostNameOrAddress, requestCallback, stateObject);

			GetHostEntryNameCallback c = new GetHostEntryNameCallback (GetHostEntry);
			return c.BeginInvoke (hostNameOrAddress, requestCallback, stateObject);
		}
Пример #8
0
		public static IAsyncResult BeginGetHostEntry (string hostNameOrAddress, AsyncCallback requestCallback, object stateObject)
		{
#if FEATURE_NO_BSD_SOCKETS
			throw new PlatformNotSupportedException ("System.Net.Dns:GetHostEntry is not supported on this platform.");
#else
			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 BeginAsyncCall (hostNameOrAddress, requestCallback, stateObject);
#endif

			GetHostEntryNameCallback c = new GetHostEntryNameCallback (GetHostEntry);
			return c.BeginInvoke (hostNameOrAddress, requestCallback, stateObject);
#endif // FEATURE_NO_BSD_SOCKETS
		}