ReceiveBufferSize Property

TcpClient.ReceiveBufferSize Property

Gets or sets the size of the receive buffer.

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

member ReceiveBufferSize : int with get, set

Property Value

Type: System.Int32
The size of the receive buffer, in bytes. The default value is 8192 bytes.


An error occurred when setting the buffer size.


In .NET Compact Framework applications, you cannot set this property. For a workaround, see the Platform Note in Remarks.

The ReceiveBufferSize property gets or sets the number of bytes that you are expecting to store in the receive buffer for each read operation. This property actually manipulates the network buffer space allocated for receiving incoming data.

Your network buffer should be at least as large as your application buffer to ensure that the desired data will be available when you call the NetworkStream.Read method. Use the ReceiveBufferSize property to set this size. If your application will be receiving bulk data, you should pass the Read method a very large application buffer.

If the network buffer is smaller than the amount of data you request in the Read method, you will not be able to retrieve the desired amount of data in one read operation. This incurs the overhead of additional calls to the Read method.

The following code example sets and gets the receive buffer size.

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

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

© 2016 Microsoft