This documentation is archived and is not being maintained.

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 Value

Type: System.Boolean
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->NoDelay = true;

   // Determines if the delay is enabled by using the NoDelay property.
   if (tcpClient->NoDelay == true)
	    Console::WriteLine(S"The delay was set successfully to {0}", __box(tcpClient->NoDelay));

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

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0
Show: