Exemple #1
0
        public static IAsyncResult BeginResolve
            (String hostName, AsyncCallback requestedCallback,
            Object stateObject)
        {
            // TODO
            DnsAsyncResult result = new DnsAsyncResult(requestedCallback,
                                                       stateObject, DnsOperation.Resolve);

            result.BeginInvoke(hostName);
            return((IAsyncResult)(result));
        }
Exemple #2
0
        static void OnCompleted(object sender, SimpleResolverEventArgs e)
        {
            DnsAsyncResult ares  = (DnsAsyncResult)e.UserToken;
            IPHostEntry    entry = e.HostEntry;

            if (entry == null || e.ResolverError != 0)
            {
                ares.SetCompleted(false, new Exception("Error: " + e.ResolverError));
                return;
            }
            ares.SetCompleted(false, entry);
        }
Exemple #3
0
        static IAsyncResult BeginAsyncCallAddresses(string host, AsyncCallback callback, object state)
        {
            SimpleResolverEventArgs e = new SimpleResolverEventArgs();

            e.Completed += OnCompleted;
            e.HostName   = host;
            DnsAsyncResult ares = new DnsAsyncResult(callback, state);

            e.UserToken = ares;
            if (resolver.GetHostAddressesAsync(e) == false)
            {
                ares.SetCompleted(true, e.HostEntry);                  // Completed synchronously
            }
            return(ares);
        }
Exemple #4
0
        static IPHostEntry EndAsyncCall(DnsAsyncResult ares)
        {
            if (ares == null)
            {
                throw new ArgumentException("Invalid asyncResult");
            }
            if (!ares.IsCompleted)
            {
                ares.AsyncWaitHandle.WaitOne();
            }
            if (ares.Exception != null)
            {
                throw ares.Exception;
            }
            IPHostEntry entry = ares.HostEntry;

            if (entry == null || entry.AddressList == null || entry.AddressList.Length == 0)
            {
                Error_11001(entry.HostName);
            }
            return(entry);
        }
Exemple #5
0
		static IAsyncResult BeginAsyncCall (string host, AsyncCallback callback, object state)
		{
			SimpleResolverEventArgs e = new SimpleResolverEventArgs ();
			e.Completed += OnCompleted;
			e.HostName = host;
			DnsAsyncResult ares = new DnsAsyncResult (callback, state);
			e.UserToken = ares;
			if (resolver.GetHostEntryAsync (e) == false)
				ares.SetCompleted (true, e.HostEntry); // Completed synchronously
			return ares;
		}
Exemple #6
0
		static IPHostEntry EndAsyncCall (DnsAsyncResult ares)
		{
			if (ares == null)
				throw new ArgumentException ("Invalid asyncResult");
			if (!ares.IsCompleted)
				ares.AsyncWaitHandle.WaitOne ();
			if (ares.Exception != null)
				throw ares.Exception;
			IPHostEntry entry = ares.HostEntry;
			if (entry == null || entry.AddressList == null || entry.AddressList.Length == 0)
				throw new SocketException(11001);
			return entry;
		}
Exemple #7
0
	public static IAsyncResult BeginResolve
		(String hostName, AsyncCallback requestedCallback,
		 Object stateObject)
			{
				// TODO
				DnsAsyncResult result=new DnsAsyncResult(requestedCallback,
									stateObject,DnsOperation.Resolve);
				result.BeginInvoke(hostName);
				return (IAsyncResult) (result);				
			}
Exemple #8
0
        static void CB(object _this)
        {
            DnsAsyncResult ares = (DnsAsyncResult)_this;

            ares.callback(ares);
        }