override internal IAsyncResult BeginReceive(
            byte[] buffer,
            int offset,
            int size,
            AsyncCallback callback,
            object state
            )
        {
            Receive_SO stateObj = null;

            CheckDisposed();
            stateObj = new Receive_SO(callback, state);
            if ((stateObj.Read = FetchBufferData(buffer, offset, size)) > 0)
            {
                stateObj.SetCompleted();
            }
            else
            {
                _socket.BeginReceive(buffer,
                                     offset,
                                     size,
                                     SocketFlags.None,
                                     new AsyncCallback(Receive_End),
                                     stateObj);
            }
            return(stateObj);
        }
Пример #2
0
        internal override IAsyncResult BeginReceive(byte[] buffer, int offset, int size, AsyncCallback callback, object state)
        {
            Receive_SO e_so = null;

            base.CheckDisposed();
            e_so = new Receive_SO(callback, state);
            if ((e_so.Read = this.FetchBufferData(buffer, offset, size)) > 0)
            {
                e_so.SetCompleted();
                return(e_so);
            }
            base._socket.BeginReceive(buffer, offset, size, SocketFlags.None, new AsyncCallback(this.Receive_End), e_so);
            return(e_so);
        }
        void Receive_End(IAsyncResult ar)
        {
            Receive_SO stateObj = (Receive_SO)ar.AsyncState;

            try
            {
                stateObj.UpdateContext();
                stateObj.Read = _socket.EndReceive(ar);
            }
            catch (Exception e)
            {
                stateObj.Exception = e;
            }
            stateObj.SetCompleted();
        }
Пример #4
0
        private void Receive_End(IAsyncResult ar)
        {
            Receive_SO asyncState = (Receive_SO)ar.AsyncState;

            try
            {
                asyncState.UpdateContext();
                asyncState.Read = base._socket.EndReceive(ar);
            }
            catch (Exception exception)
            {
                asyncState.Exception = exception;
            }
            asyncState.SetCompleted();
        }
		override internal IAsyncResult BeginReceive(
			byte[] buffer,
			int offset,
			int size,
			AsyncCallback callback,
			object state
			)
		{
			Receive_SO stateObj = null;

			CheckDisposed();
			stateObj = new Receive_SO(callback, state);
			if((stateObj.Read = FetchBufferData(buffer, offset, size)) > 0)
			{
				stateObj.SetCompleted();
			}
			else
			{
				_socket.BeginReceive(buffer, 
					offset, 
					size,
					SocketFlags.None,
					new AsyncCallback(Receive_End), 
					stateObj);
			}
			return stateObj;
		}