IAsyncResult PrepareSyncReadResult(int readBytes, object state) { SSLSyncResult <int> result = new SSLSyncResult <int>(); result.Result = readBytes; result.AsyncState = state; return(result); }
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { _curwritePacket = null; Write(buffer, offset, count); if ((_state & SSLHandlerState.Authenticating) != 0 && _needRead) { //如果是在握手阶段则使用异步,需要读取才结束 _AsyncWrite = new SSLAsyncResult <int>(); _AsyncWrite.Callback = callback; _AsyncWrite.AsyncState = state; return(_AsyncWrite); } else { SSLSyncResult <int> result = new SSLSyncResult <int>(); result.AsyncState = state; return(result); } }