TcpClient.SendBufferSize Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the size of the send buffer.
public:
property int SendBufferSize { int get(); void set(int value); };
public int SendBufferSize { get; set; }
member this.SendBufferSize : int with get, set
Public Property SendBufferSize As Integer
The size of the send buffer, in bytes. The default value is 8192 bytes.
The following code example sets and gets the send buffer size.
//sets the send buffer size using the SendBufferSize public property.
tcpClient->SendBufferSize = 1024;
// gets the send buffer size using the SendBufferSize public property.
if ( tcpClient->SendBufferSize == 1024 )
Console::WriteLine( "The send buffer was successfully set to {0}", tcpClient->SendBufferSize );
// Sets the send buffer size using the SendBufferSize public property.
tcpClient.SendBufferSize = 1024;
// Gets the send buffer size using the SendBufferSize public property.
if (tcpClient.SendBufferSize == 1024)
Console.WriteLine ("The send buffer was successfully set to " + tcpClient.SendBufferSize.ToString ());
'Sets the send buffer size using the SendBufferSize public property.
tcpClient.SendBufferSize = 1024
' Gets the send buffer size using the SendBufferSize public property.
If tcpClient.SendBufferSize = 1024 Then
Console.WriteLine(("The send buffer was successfully set to " + tcpClient.SendBufferSize.ToString()))
End If
The SendBufferSize
property gets or sets the number of bytes that you are expecting to send in each call to the NetworkStream.Write method. This property actually manipulates the network buffer space allocated for send operation.
Your network buffer should be at least as large as your application buffer to ensure that the desired data will be stored and sent in one operation. Use the SendBufferSize property to set this size. If your application will be sending bulk data, you should pass the Write
method a very large application buffer.
If the network buffer is smaller than the amount of data you provide the Write
method, several network send operations will be performed for every call you make to the Write
method. You can achieve greater data throughput by ensuring that your network buffer is at least as large as your application buffer.
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.3, 1.4, 1.6, 2.0, 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: