title: Socket "Flush" by temporarily enabling NoDelay
body: <h1>Background</h1>
  <p>I have an implementation of an HTTP server in C#.
  Using <a href="http://httpd.apache.org/docs/2.0/programs/ab.html" rel="nofollow noreferrer">ab</a> I discovered a weird performance issue.
  Each request took 5 ms with Keep-Alive Off but 40 ms with Keep-Alive on!</p>
  <p>The testpage is generated into a single byte[] which get sent as reply using a single socket.Send call.</p>
  <p>The cause is as far as I can tell Nagle's algorithm used in the TCP stack.</p>
  <h1>TCP Flush?</h1>
  <p>So far I am using the <a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.nodelay.aspx#Y640" rel="nofollow noreferrer">NoDelay</a> property in the end of every HTTP request served.</p>
  <pre><code>socket.NoDelay = true;
  socket.NoDelay = false;
  </code></pre>
  <p>Which does solve the problem for now. But I have no documentation to backup my discovery.</p>
  <p>This was tested on a linux/mono system.</p>
  <p><strong>Is there a standard way of flushing the TCP connection?</strong></p>
  <h1>Related</h1>
  <p><a href="https://stackoverflow.com/questions/1781766/paste-httpserver-and-slowdown-with-http-1-1-keep-alive-tested-with-httperf-and-a/1795352#1795352">This answer</a> is addressing the same issue. The difference here is that I am looking to only temporarily disabling the algorithm.</p>