Export (0) Print
Expand All

SslStream.Read Method

Reads data from this stream and stores it in the specified array.

Namespace:  System.Net.Security
Assembly:  System (in System.dll)

abstract Read : 
        buffer:byte[] * 
        offset:int * 
        count:int -> int  
override Read : 
        buffer:byte[] * 
        offset:int * 
        count:int -> int


Type: System.Byte[]

A Byte array that receives the bytes read from this stream.

Type: System.Int32

A Int32 that contains the zero-based location in buffer at which to begin storing the data read from this stream.

Type: System.Int32

A Int32 that contains the maximum number of bytes to read from this stream.

Return Value

Type: System.Int32
A Int32 value that specifies the number of bytes read. When there is no more data to be read, returns 0.


buffer is a null reference (Nothing in Visual Basic).


offset < 0.


offset > the length of buffer.


offset + count > the length of buffer.


The read operation failed. Check the inner exception, if present to determine the cause of the failure.


There is already a read operation in progress.


This object has been closed.


Authentication has not occurred.

The method reads a maximum of count bytes from the stream and stores them in buffer beginning at offset. You cannot perform multiple simultaneous read operations.

You cannot call this method until you have successfully authenticated. To authenticate call one of the AuthenticateAsClient, or BeginAuthenticateAsClient, AuthenticateAsServer, BeginAuthenticateAsServer methods.

To perform this operation asynchronously, use the BeginRead method.

The following code example demonstrates reading from an SslStream.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft