NoDelay Property

TcpClient.NoDelay Property

Gets or sets a value that disables a delay when send or receive buffers are not full.

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

public bool NoDelay { get; set; }
/** @property */
public boolean get_NoDelay ()

/** @property */
public void set_NoDelay (boolean value)

public function get NoDelay () : boolean

public function set NoDelay (value : boolean)

Property Value

true if the delay is disabled, otherwise false. The default value is false.

When NoDelay is false, a TcpClient does not send a packet over the network until it has collected a significant amount of outgoing data. Because of the amount of overhead in a TCP segment, sending small amounts of data is inefficient. However, situations do exist where you need to send very small amounts of data or expect immediate responses from each packet you send. Your decision should weigh the relative importance of network efficiency versus application requirements.

The following code example disables the delay. It then checks the value of NoDelay to verify that the property was successfully set.

// Sends data immediately upon calling NetworkStream.Write.
tcpClient.NoDelay = true;

// Determines if the delay is enabled by using the NoDelay property.
if (tcpClient.NoDelay == true)
    Console.WriteLine ("The delay was set successfully to " + tcpClient.NoDelay.ToString ());


// Sends data immediately upon calling NetworkStream.Write.
tcpClient.set_NoDelay(true);

// Determines if the delay is enabled by using the NoDelay property.
if (tcpClient.get_NoDelay() == true) {
    Console.WriteLine("The delay was set successfully to "
        + ((System.Boolean)tcpClient.get_NoDelay()).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:
© 2016 Microsoft