// // // private static void ReadCallback(IAsyncResult transportResult) { GlobalLog.Assert(transportResult.AsyncState is FixedSizeReader, "ReadCallback|State type is wrong, expected FixedSizeReader."); if (transportResult.CompletedSynchronously) { return; } FixedSizeReader reader = (FixedSizeReader)transportResult.AsyncState; AsyncProtocolRequest request = reader._Request; // Async completion try { int bytes = reader._Transport.EndRead(transportResult); if (reader.CheckCompletionBeforeNextRead(bytes)) { return; } reader.StartReading(); } catch (Exception e) { if (request.IsUserCompleted) { throw; } request.CompleteWithError(e); } }
internal SslState(Stream innerStream, RemoteCertValidationCallback certValidationCallback, LocalCertSelectionCallback certSelectionCallback, EncryptionPolicy encryptionPolicy) { this._InnerStream = innerStream; this._Reader = new FixedSizeReader(innerStream); this._CertValidationDelegate = certValidationCallback; this._CertSelectionDelegate = certSelectionCallback; this._EncryptionPolicy = encryptionPolicy; }
private static void ReadCallback(IAsyncResult transportResult) { if (!(transportResult.AsyncState is FixedSizeReader)) { NetEventSource.Fail(null, "State type is wrong, expected FixedSizeReader."); } if (transportResult.CompletedSynchronously) { return; } FixedSizeReader reader = (FixedSizeReader)transportResult.AsyncState; AsyncProtocolRequest request = reader._request; // Async completion. try { int bytes = reader._transport.EndRead(transportResult); if (reader.CheckCompletionBeforeNextRead(bytes)) { return; } reader.StartReading(); } catch (Exception e) { if (request.IsUserCompleted) { throw; } request.CompleteUserWithError(e); } }
private static void ReadCallback(IAsyncResult transportResult) { if (!transportResult.CompletedSynchronously) { FixedSizeReader asyncState = (FixedSizeReader)transportResult.AsyncState; AsyncProtocolRequest request = asyncState._Request; try { int bytes = asyncState._Transport.EndRead(transportResult); if (!asyncState.CheckCompletionBeforeNextRead(bytes)) { asyncState.StartReading(); } } catch (Exception exception) { if (request.IsUserCompleted) { throw; } request.CompleteWithError(exception); } } }
internal _SslStream(SslState sslState) { this._SslState = sslState; this._Reader = new FixedSizeReader(this._SslState.InnerStream); }