Esempio n. 1
0
        public override int EndRead(IAsyncResult asyncResult)
        {
            SSLResult <int> result = asyncResult as SSLResult <int>;

            if (_AsyncRead != null)
            {
                _AsyncRead.SSLAsyncBuffer = default(ArraySegment <byte>);
                _AsyncRead.Callback       = null;
                _AsyncRead = null;
            }
            return(result.Result);
        }
Esempio n. 2
0
 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
 {
     if (this._inputLength - this._inputOffset > 0)
     {
         //有数据则直接读取
         int read = this.ReadFromInput(buffer, offset, count);
         return(this.PrepareSyncReadResult(read, state));
     }
     _AsyncRead = new SSLAsyncResult <int>();
     _AsyncRead.SSLAsyncBuffer = new ArraySegment <byte>(buffer, offset, count);
     _AsyncRead.Callback       = callback;
     _AsyncRead.AsyncState     = state;
     return(_AsyncRead);
 }
Esempio n. 3
0
 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);
     }
 }