Export (0) Print
Expand All

TcpClient.SendBufferSize Property

Gets or sets the size of the send buffer.

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

public int SendBufferSize { get; set; }
/** @property */
public int get_SendBufferSize ()

/** @property */
public void set_SendBufferSize (int value)

public function get SendBufferSize () : int

public function set SendBufferSize (value : int)

Property Value

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

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.

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 " + tcpClient.SendBufferSize.ToString ());


// Sets the send buffer size using the SendBufferSize public property.
tcpClient.set_SendBufferSize(1024);

// Gets the send buffer size using the SendBufferSize public property.
if (tcpClient.get_SendBufferSize() == 1024) {
    Console.WriteLine("The send buffer was successfully set to "
        + ((Int32)tcpClient.get_SendBufferSize()).ToString());
}

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft