Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 5
0
File: Dns.cs Progetto: westybsa/mono
		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;
		}
Esempio n. 6
0
File: Dns.cs Progetto: westybsa/mono
		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;
		}
Esempio n. 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);				
			}
Esempio n. 8
0
        static void CB(object _this)
        {
            DnsAsyncResult ares = (DnsAsyncResult)_this;

            ares.callback(ares);
        }