SslStream.Read Method (Byte(), Int32, Int32)


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

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

Public Overrides Function Read (
	buffer As Byte(),
	offset As Integer,
	count As Integer
) As Integer


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.

Exception Condition

buffer is null.




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
Available since 2.0
Return to top