System.Net.Security.SslStream.BeginRead C# (CSharp) Method

BeginRead() public method

public BeginRead ( byte buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState ) : IAsyncResult
buffer byte
offset int
count int
asyncCallback AsyncCallback
asyncState object
return IAsyncResult
        public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
        {
            return _sslState.SecureStream.BeginRead(buffer, offset, count, asyncCallback, asyncState);
        }

Usage Example

Example #1
0
        public void ConnectSecure(string hostname, int port, bool useEvents = true, bool validateServerCertificate = true)
        {
            if (Client.Connected)
            {
                throw new InvalidOperationException("Unable to connect: client is already connected");
            }

            Client.Connect(hostname, port);
            if (OnLocalPortKnown != null)
            {
                Task.Run(() => OnLocalPortKnown(((IPEndPoint)Client.Client.LocalEndPoint).Port));
            }
            var sslStream = new SslStream(Client.GetStream(), false, validateServerCertificate ? new RemoteCertificateValidationCallback(ValidateServerCertificate) : null, null);
            sslStream.AuthenticateAsClient(hostname);

            Log(string.Format("SSL Connection established: Cipher: {0}-bit {1}; KEX: {2} {3}-bit; Hash: {4} {5}-bit",
                sslStream.CipherStrength, sslStream.CipherAlgorithm,
                sslStream.KeyExchangeAlgorithm, sslStream.KeyExchangeStrength,
                sslStream.HashAlgorithm, sslStream.HashStrength));
            ConnectionStream = sslStream;

            readBuffer = new byte[Client.ReceiveBufferSize];
            if (useEvents)
            {
                EnterReadLoop();
                sslStream.BeginRead(readBuffer, 0, readBuffer.Length, ReadCallback, Client);
            }
        }
All Usage Examples Of System.Net.Security.SslStream::BeginRead