public void Start() { _socket.BeginReceive(_nextInputSegment); if (_nextInputSegment.IsCompleted) { CompleteRead(); } else { _nextInputSegment.OnCompleted(completeReadDelegate); } }
public void Start() { _nextInputSegment = _nextInputSegment ?? _socket.ReceiveBufferPool.GetBuffer(); _currentInputSegment = _currentInputSegment ?? _socket.ReceiveBufferPool.GetBuffer(); _socket.BeginReceive(_nextInputSegment); if (_nextInputSegment.IsCompleted) { CompleteRead(); } else { _nextInputSegment.OnCompleted(completeReadDelegate); } }
private void GetNewSegment() { _currentInputSegment = _incommingSegments.GetResult(); if (_currentInputSegment == null) { _readtcs.SetResult(0); return; } _bytesReadInCurrentSegment = 0; _currentContentLength = _currentInputSegment.CurrentContentLength; if (_currentContentLength == 0) { _currentInputSegment.Dispose(); _currentInputSegment = null; _readtcs.SetResult(0); return; } else { _socket.BeginReceive(); CompleteRead(); } }
public RioStream(RioSocket socket) { _socket = socket; _currentInputSegment = null; _currentOutputSegment = _socket.SendBufferPool.GetBuffer(); _getNewSegmentDelegate = GetNewSegment; socket.OnIncommingSegmentUnsafe = (sock, s) => _incommingSegments.Set(s); socket.BeginReceive(); }
public RioStream(RioSocket socket) { _socket = socket; _currentInputSegment = _socket.ReceiveBufferPool.GetBuffer(); _currentOutputSegment = _socket.SendBufferPool.GetBuffer(); _nextInputSegment = _socket.ReceiveBufferPool.GetBuffer(); _getNewSegmentDelegateDelegate = GetNewSegmentDelegateWrapper; _outputSegmentTotalLength = _currentOutputSegment.TotalLength; _remainingSpaceInOutputSegment = _outputSegmentTotalLength; _socket.BeginReceive(_nextInputSegment); _waitCallback = WaitCallbackcallback; }
int GetNewSegment() { if (_nextInputSegment.CurrentContentLength == 0) { _nextInputSegment.Dispose(); _currentInputSegment.Dispose(); return(0); } else { _bytesReadInCurrentSegment = 0; _nextInputSegment = _socket.BeginReceive(Interlocked.Exchange(ref _currentInputSegment, _nextInputSegment)); return(CompleteRead()); } }
public FlippingRioStream(RioSocket socket) { _socket = socket; _currentInputSegment = _socket.ReceiveBufferPool.GetBuffer(); _currentOutputSegment = _socket.SendBufferPool.GetBuffer(); _nextInputSegment = _socket.ReceiveBufferPool.GetBuffer(); if (_nextInputSegment._awaitableState != RioBufferSegment._notStarted) { } _getNewSegmentDelegateDelegate = GetNewSegmentDelegateWrapper; _outputSegmentTotalLength = _currentOutputSegment.TotalLength; _remainingSpaceInOutputSegment = _outputSegmentTotalLength; _socket.BeginReceive(_nextInputSegment); _waitCallback = WaitCallbackcallback; }
private int GetNewSegment() { var tmp = _currentInputSegment; _nextInputSegment.GetResult(); _currentInputSegment = _nextInputSegment; _bytesReadInCurrentSegment = 0; _currentContentLength = _currentInputSegment.CurrentContentLength; if (_currentContentLength == 0) { _currentInputSegment.Dispose(); tmp.Dispose(); return 0; } else { _nextInputSegment = tmp; _socket.BeginReceive(_nextInputSegment); return CompleteRead(); } }