public SetNextRequest ( byte buffer, int offset, int count, AsyncProtocolCallback callback ) : void | ||
buffer | byte | |
offset | int | |
count | int | |
callback | AsyncProtocolCallback | |
리턴 | void |
private void StartWriting(byte[] buffer, int offset, int count, AsyncProtocolRequest asyncRequest) { if (asyncRequest != null) { asyncRequest.SetNextRequest(buffer, offset, count, _ResumeAsyncWriteCallback); } if (count >= 0) { byte[] outBuffer = null; do { int num2; if (this._SslState.CheckEnqueueWrite(asyncRequest)) { return; } int num = Math.Min(count, this._SslState.MaxDataSize); SecurityStatus errorCode = this._SslState.EncryptData(buffer, offset, num, ref outBuffer, out num2); if (errorCode != SecurityStatus.OK) { ProtocolToken token = new ProtocolToken(null, errorCode); throw new IOException(SR.GetString("net_io_encrypt"), token.GetException()); } if (asyncRequest != null) { asyncRequest.SetNextRequest(buffer, offset + num, count - num, _ResumeAsyncWriteCallback); IAsyncResult asyncResult = this._SslState.InnerStream.BeginWrite(outBuffer, 0, num2, _WriteCallback, asyncRequest); if (!asyncResult.CompletedSynchronously) { return; } this._SslState.InnerStream.EndWrite(asyncResult); } else { this._SslState.InnerStream.Write(outBuffer, 0, num2); } offset += num; count -= num; this._SslState.FinishWrite(); } while (count != 0); } if (asyncRequest != null) { asyncRequest.CompleteUser(); } }
private int StartReading(byte[] buffer, int offset, int count, AsyncProtocolRequest asyncRequest) { int num = 0; Label_0002: if (asyncRequest != null) { asyncRequest.SetNextRequest(buffer, offset, count, _ResumeAsyncReadCallback); } int userResult = this._SslState.CheckEnqueueRead(buffer, offset, count, asyncRequest); switch (userResult) { case 0: return 0; case -1: num = this.StartFrameHeader(buffer, offset, count, asyncRequest); if (num == -1) { goto Label_0002; } return num; } if (asyncRequest != null) { asyncRequest.CompleteUser(userResult); } return userResult; }
private int StartFrameHeader(byte[] buffer, int offset, int count, AsyncProtocolRequest asyncRequest) { int readBytes = 0; this.EnsureInternalBufferSize(0, this._SslState.HeaderSize); if (asyncRequest != null) { asyncRequest.SetNextRequest(this.InternalBuffer, 0, this._SslState.HeaderSize, _ReadHeaderCallback); this._Reader.AsyncReadPacket(asyncRequest); if (!asyncRequest.MustCompleteSynchronously) { return 0; } readBytes = asyncRequest.Result; } else { readBytes = this._Reader.ReadPacket(this.InternalBuffer, 0, this._SslState.HeaderSize); } return this.StartFrameBody(readBytes, buffer, offset, count, asyncRequest); }
private int StartFrameBody(int readBytes, byte[] buffer, int offset, int count, AsyncProtocolRequest asyncRequest) { if (readBytes == 0) { this.DecrementInternalBufferCount(this.InternalBufferCount); if (asyncRequest != null) { asyncRequest.CompleteUser(0); } return 0; } readBytes = this._SslState.GetRemainingFrameSize(this.InternalBuffer, readBytes); if (readBytes < 0) { throw new IOException(SR.GetString("net_frame_read_size")); } this.EnsureInternalBufferSize(this._SslState.HeaderSize, readBytes); if (asyncRequest != null) { asyncRequest.SetNextRequest(this.InternalBuffer, this._SslState.HeaderSize, readBytes, _ReadFrameCallback); this._Reader.AsyncReadPacket(asyncRequest); if (!asyncRequest.MustCompleteSynchronously) { return 0; } readBytes = asyncRequest.Result; } else { readBytes = this._Reader.ReadPacket(this.InternalBuffer, this._SslState.HeaderSize, readBytes); } return this.ProcessFrameBody(readBytes, buffer, offset, count, asyncRequest); }
private void StartReceiveBlob(byte[] buffer, AsyncProtocolRequest asyncRequest) { if (this._PendingReHandshake) { if (this.CheckEnqueueHandshakeRead(ref buffer, asyncRequest)) { return; } if (!this._PendingReHandshake) { this.ProcessReceivedBlob(buffer, buffer.Length, asyncRequest); return; } } buffer = EnsureBufferSize(buffer, 0, this.Context.HeaderSize); int readBytes = 0; if (asyncRequest == null) { readBytes = this._Reader.ReadPacket(buffer, 0, this.Context.HeaderSize); } else { asyncRequest.SetNextRequest(buffer, 0, this.Context.HeaderSize, _PartialFrameCallback); this._Reader.AsyncReadPacket(asyncRequest); if (!asyncRequest.MustCompleteSynchronously) { return; } readBytes = asyncRequest.Result; } this.StartReadFrame(buffer, readBytes, asyncRequest); }
private void StartReadFrame(byte[] buffer, int readBytes, AsyncProtocolRequest asyncRequest) { if (readBytes == 0) { throw new IOException(SR.GetString("net_auth_eof")); } if (this._Framing == Framing.None) { this._Framing = this.DetectFraming(buffer, readBytes); } int remainingFrameSize = this.GetRemainingFrameSize(buffer, readBytes); if (remainingFrameSize < 0) { throw new IOException(SR.GetString("net_ssl_io_frame")); } if (remainingFrameSize == 0) { throw new AuthenticationException(SR.GetString("net_auth_eof"), null); } buffer = EnsureBufferSize(buffer, readBytes, readBytes + remainingFrameSize); if (asyncRequest == null) { remainingFrameSize = this._Reader.ReadPacket(buffer, readBytes, remainingFrameSize); } else { asyncRequest.SetNextRequest(buffer, readBytes, remainingFrameSize, _ReadFrameCallback); this._Reader.AsyncReadPacket(asyncRequest); if (!asyncRequest.MustCompleteSynchronously) { return; } remainingFrameSize = asyncRequest.Result; if (remainingFrameSize == 0) { readBytes = 0; } } this.ProcessReceivedBlob(buffer, readBytes + remainingFrameSize, asyncRequest); }