title: Indy Write Buffering / Efficient TCP communication
body: <p>I know, I'm asking a lot of questions...but as a new delphi developer I keep falling over all these questions :)</p>
  
  <p>This one deals with TCP communication using indy 10. To make communication efficient, I code a client operation request as a single byte (in most scenarios followed by other data bytes of course, but in this case only one single byte). Problem is that</p>
  
  <pre><code>var Bytes : TBytes;
  ...
  SetLength (Bytes, 1);
  Bytes [0] := OpCode;
  FConnection.IOHandler.Write (Bytes, 1);
  ErrorCode := Connection.IOHandler.ReadByte;
  </code></pre>
  
  <p>does not send that byte immediately (at least the servers execute handler is not invoked). If I change the '1' to a '9' for example everything works fine. I assumed that Indy buffers the outgoing bytes and tried to disable write buffering with</p>
  
  <pre><code>FConnection.IOHandler.WriteBufferClose;
  </code></pre>
  
  <p>but it did not help. How can I send a single byte and make sure that it is immediatly sent? And - I add another little question here - what is the best way to send an integer using indy? Unfortunately I can't find function like WriteInteger in the IOHandler of TIdTCPServer...and</p>
  
  <pre><code>WriteLn (IntToStr (SomeIntVal))
  </code></pre>
  
  <p>seems not very efficient to me. Does it make a difference whether I use multiple write commands in a row or pack things together in a byte array and send that once?</p>
  
  <p>Thanks for any answers!</p>
  
  <p>EDIT: I added a hint that I'm using Indy 10 since there seem to be major changes concerning the read and write procedures.</p>