TcpClient.NoDelay Property
Definition
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 a value that disables a delay when send or receive buffers are not full.
public:
property bool NoDelay { bool get(); void set(bool value); };
public bool NoDelay { get; set; }
member this.NoDelay : bool with get, set
Public Property NoDelay As Boolean
Property Value
true
if the delay is disabled; otherwise, false
. The default value is false
.
Examples
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 {0}", tcpClient->NoDelay );
// 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 Then
Console.WriteLine(("The delay was set successfully to " + tcpClient.NoDelay.ToString()))
End If
Remarks
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.
Applies to
Зворотний зв’язок
https://aka.ms/ContentUserFeedback.
Очікується незабаром: протягом 2024 року ми будемо припиняти використання механізму реєстрації проблем у GitHub для зворотного зв’язку щодо вмісту й замінювати його новою системою зворотного зв’язку. Докладніше:Надіслати й переглянути відгук про