private bool ContinueReading() { while (true) { if (this.size == 0) { if (readCallback == null) { readCallback = new WaitCallback(ConnectionModeReader.ReadCallback); } if (base.Connection.BeginRead(0, base.Connection.AsyncReadBufferSize, this.GetRemainingTimeout(), readCallback, this) == AsyncReadResult.Queued) { return(false); } if (!this.GetReadResult()) { return(false); } } do { int num; try { num = this.decoder.Decode(this.buffer, this.offset, this.size); } catch (CommunicationException exception) { string str; if (FramingEncodingString.TryGetFaultString(exception, out str)) { byte[] drainBuffer = new byte[0x80]; InitialServerConnectionReader.SendFault(base.Connection, str, drainBuffer, this.GetRemainingTimeout(), base.MaxViaSize + base.MaxContentTypeSize); base.Close(this.GetRemainingTimeout()); } throw; } if (num > 0) { this.offset += num; this.size -= num; } if (this.decoder.CurrentState == ServerModeDecoder.State.Done) { return(true); } }while (this.size != 0); } }
bool ContinueReading() { for (;;) { if (size == 0) { if (readCallback == null) { readCallback = new WaitCallback(ReadCallback); } if (Connection.BeginRead(0, Connection.AsyncReadBufferSize, GetRemainingTimeout(), readCallback, this) == AsyncCompletionResult.Queued) { break; } if (!GetReadResult()) // we're at EOF, bail { return(false); } } for (;;) { int bytesDecoded; try { bytesDecoded = decoder.Decode(buffer, offset, size); } catch (CommunicationException e) { // see if we need to send back a framing fault string framingFault; if (FramingEncodingString.TryGetFaultString(e, out framingFault)) { byte[] drainBuffer = new byte[128]; InitialServerConnectionReader.SendFault( Connection, framingFault, drainBuffer, GetRemainingTimeout(), MaxViaSize + MaxContentTypeSize); base.Close(GetRemainingTimeout()); } throw; } if (bytesDecoded > 0) { offset += bytesDecoded; size -= bytesDecoded; } if (decoder.CurrentState == ServerModeDecoder.State.Done) { return(true); } if (size == 0) { break; } } } return(false); }