System.Net.Sockets.TcpClient.ReceiveBufferSize Property

Gets or sets the size of the receive buffer.

Syntax

public int ReceiveBufferSize { get; set; }

Value

The buffer size.

Remarks

The TcpClient.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(Byte[], int, int) method. Use the TcpClient.ReceiveBufferSize property to set this size. If your application will be receiving bulk data, you should pass the NetworkStream.Read(Byte[], int, int) method a very large application buffer.

If the network buffer is smaller than the amount of data you request in the NetworkStream.Read(Byte[], int, int) 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 NetworkStream.Read(Byte[], int, int) method.

Requirements

Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0