Esempio n. 1
0
 private bool TryBeginRead(byte[] buffer,
                           int offset,
                           int size,
                           AsyncCallback callback,
                           ChannelState state)
 {
     try
     {
         _stream.BeginRead(buffer, offset, size, callback, state);
         return(true);
     }
     catch (ObjectDisposedException e)
     {
         _log.Warn("Stream disposed", e);
         return(false);
     }
     catch (IOException e)
     {
         _log.Warn("Unable to attempt reading data", e);
         OnDisconnect?.Invoke(state.Client);
         return(false);
     }
 }
Esempio n. 2
0
 private void AwaitBody(ChannelState state)
 {
     TryBeginRead(_buffer, 0, Math.Min(BufferLength, _bytesNeed - _bytesRead), AwaitBodyCompleted, state);
 }
Esempio n. 3
0
 private void AwaitHeader(ChannelState state)
 {
     TryBeginRead(_buffer, _bytesRead, _bytesNeed - _bytesRead, AwaitHeaderCompleted, state);
 }