I have a very simple code snippet that tries to send data via TcpClient
and its associated NetworkStream
.
var client = new TcpClien
Set TcpClient.NoDelay to true
so that Nagle's algorithm isn't used.
From the MSDN Library documentation:
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.