/// <summary> /// returns true if io is pending /// </summary> /// <param name="p"></param> /// <returns></returns> public bool Read(AsyncIOArgs p) { var count = p.Count; if (count < 1) throw new ArgumentOutOfRangeException("count", "count must be > 0"); #if DEBUG_IO if (Interlocked.CompareExchange(ref this.doingIO, 1, 0) != 0) throw new InvalidOperationException("Receive is already in progress"); #endif this.expectedToRead = p.Count; this.pendingArgs = p; p.Fail = false; p.Result = null; if (this.asyncBuffer.Available >= count) { PublishResult(false); return false; } else { this.remainingRead = count - this.asyncBuffer.Available; this.isAborted = 0; this.BeginReceive(); return true; } }
/// <summary> /// Receives data asynchronously. Returns true if the IO is pending. Returns false if the socket already failed or the data was available in the buffer. /// p.Next will only be called if the call completes asynchronously. /// </summary> public bool ReceiveAsync(AsyncIOArgs p) { this.CheckDisposed(); if (!this.IsAlive) { p.Fail = true; p.Result = null; return(false); } if (this.helper == null) { this.helper = new AsyncSocketHelper(this); } return(this.helper.Read(p)); }
/// <summary> /// returns true if io is pending /// </summary> /// <param name="p"></param> /// <returns></returns> public bool Read(AsyncIOArgs p) { var count = p.Count; if (count < 1) { throw new ArgumentOutOfRangeException("count", "count must be > 0"); } #if DEBUG_IO if (Interlocked.CompareExchange(ref this.doingIO, 1, 0) != 0) { throw new InvalidOperationException("Receive is already in progress"); } #endif this.expectedToRead = p.Count; this.pendingArgs = p; p.Fail = false; p.Result = null; if (this.asyncBuffer.Available >= count) { PublishResult(false); return(false); } else { this.remainingRead = count - this.asyncBuffer.Available; this.isAborted = 0; this.BeginReceive(); return(true); } }
/// <summary> /// Receives data asynchronously. Returns true if the IO is pending. Returns false if the socket already failed or the data was available in the buffer. /// p.Next will only be called if the call completes asynchronously. /// </summary> public bool ReceiveAsync(AsyncIOArgs p) { this.CheckDisposed(); if (!this.IsAlive) { p.Fail = true; p.Result = null; return false; } if (this.helper == null) this.helper = new AsyncSocketHelper(this); return this.helper.Read(p); }
public bool ReceiveAsync(AsyncIOArgs p) { CheckDisposed(); if (!IsAlive) { p.Fail = true; p.Result = null; return false; } if (_helper2 == null) { _helper2 = new AsyncSocketHelper2(this); } return _helper2.Read(p); }