共用方式為


TcpClient.NoDelay 屬性

定義

取得或設定值,在傳送或接收緩衝區未滿時停用延遲。

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

屬性值

true 如果延遲已停用,則為 ;否則為 false。 預設值是 false

範例

下列程式代碼範例會停用延遲。 接著會檢查的值 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 {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

備註

當 為 falseNoDelayTcpClient在收集大量傳出數據之前,不會透過網路傳送封包。 由於 TCP 區段中的額外負荷,因此傳送少量的數據沒有效率。 不過,在某些情況下,您需要傳送非常少量的數據,或預期會立即回應您傳送的每個封包。 您的決策應該考慮網路效率與應用程式需求的相對重要性。

適用於