Export (0) Print
Expand All

TcpClient.SendBufferSize Property

Gets or sets the size of the send buffer.

[Visual Basic]
Public Property SendBufferSize As Integer
[C#]
public int SendBufferSize {get; set;}
[C++]
public: __property int get_SendBufferSize();
public: __property void set_SendBufferSize(int);
[JScript]
public function get SendBufferSize() : int;
public function set SendBufferSize(int);

Property Value

The size of the send buffer, in bytes. The default value is 8192 bytes.

Remarks

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.

Example

[Visual Basic, C#, C++] The following example sets and gets the send buffer size.

[Visual Basic] 
'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

[C#] 
// 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 ());


[C++] 
//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(S"The send buffer was successfully set to {0}", __box(tcpClient->SendBufferSize));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

TcpClient Class | TcpClient Members | System.Net.Sockets Namespace | ReceiveBufferSize | Write

Show:
© 2014 Microsoft