title: Indy TCP - Read data in a loop
body: <p>A TCP server is sending data frames continuosly every 8ms. I want to program a client able to receive these data frames. Is there any procedure in Indy 9 to know if there is data available in the buffer?</p>
  
  <p>My current programs is the following (I am using a Thread):</p>
  
  <pre><code>procedure TThreadRead.Execute;
  var
    buffer: array [0..755] of byte;
    //s1: string;
    //i: integer;
  begin
    IdTCPClient1.RecvBufferSize:= 756;
    IdTCPClient1.Connect;
    while Terminated = false do
    begin
      if IdTCPClient1.InputBuffer.Size = 0 then
         IdTCPClient1.ReadFromStack(True,0,False);
      while IdTCPClient1.InputBuffer.Size &gt; 0 do
      begin
         ReadBuffer(buffer, FClient.InputBuffer.Size);
         //s1:= '';
         //For i:=0 To Length(buffer)-1 Do
         //  s1:=s1+IntToHex(Ord(buffer[i]),2); //Read values--&gt;global var
         //Form1.Memo1.Text:=s1;
      end;
    end;
  end;
  </code></pre>
  
  <p>Is there any more efficient solution for reading TCP data continuously (like onread event in UDP)?</p>
  
  <p>Thanks in advance.</p>