public bool StartRead(ref ArraySegment <byte> buffer, ref int offset, AsyncCallback callback, object state) { if (!_isConnected) { return(_delegate.StartRead(ref buffer, ref offset, callback, state)); } else if (SslStream == null) { throw new ConnectionLostException(); } Debug.Assert(SslStream.IsAuthenticated); int packetSize = GetRecvPacketSize(buffer.Count - offset); try { _readCallback = callback; _readResult = SslStream.BeginRead(buffer.Array, buffer.Offset + offset, packetSize, ReadCompleted, state); return(_readResult.CompletedSynchronously); } catch (IOException ex) { if (Network.ConnectionLost(ex)) { throw new ConnectionLostException(ex); } if (Network.Timeout(ex)) { throw new ConnectionTimeoutException(); } throw new TransportException(ex); } catch (ObjectDisposedException ex) { throw new ConnectionLostException(ex); } }