Example #1
0
        public override Socket EndAccept(IAsyncResult asyncResult)
        {
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }

            SockAccept s = asyncResult as SockAccept;

            if (s == null || s.socket != socket)
            {
                throw new ArgumentException(
                          "Result was not produced by current instance.",
                          "asyncResult");
            }

            if (!s.IsCompleted)
            {
                s.AsyncWaitHandle.WaitOne();
            }

            if (s.except != null)
            {
                throw s.except;
            }

            UnmanagedSocket u = new UnmanagedSocket(s.accepted);

            u.connected = true;
            return(u);
        }
Example #2
0
        public override IAsyncResult BeginAccept(AsyncCallback callback,
                                                 object state)
        {
            var s = new SockAccept(socket, callback, state);

            ThreadPool.QueueUserWorkItem(s.Run);
            return(s);
        }
		public override IAsyncResult BeginAccept (AsyncCallback callback,
		                                 object state)
		{
			SockAccept s = new SockAccept (socket, callback, state);
			ThreadPool.QueueUserWorkItem (s.Run);
			return s;
		}