title: How to write and read Stream using indy 10.5.5 c++
body: <p>Hi I have try to read Stream from the server with this code</p>
  
  <pre><code>void __fastcall TForm1::Edit1KeyPress(TObject *Sender, wchar_t &amp;Key)
  {
     //TMemoryStream *TMS = new TMemoryStream;
     TStringStream *TSS = new TStringStream;
     AnsiString A,B;
     TStream *TS;
     INT64 Len;
     try
     {
         if (Key == VK_RETURN)
         {
            Beep(0,0);
            if(Edit1-&gt;Text == "mystream")
             {
                 TCPClient1-&gt;IOHandler-&gt;WriteLn("mystream");
                 Len = StrToInt(TCPClient1-&gt;IOHandler-&gt;ReadLn());
                 TCPClient1-&gt;IOHandler-&gt;ReadStream(TS,Len,false);
                 TSS-&gt;CopyFrom(TS,0);
                 RichEdit1-&gt;Lines-&gt;Text = TSS-&gt;DataString;
                 Edit1-&gt;Clear();
             }
         else
             {
                TCPClient1-&gt;IOHandler-&gt;WriteLn(Edit1-&gt;Text);
                A = TCPClient1-&gt;IOHandler-&gt;ReadLn();
                RichEdit1-&gt;Lines-&gt;Add(A);
                Edit1-&gt;Clear();
             }
         }
     }
     __finally
     {
         TSS-&gt;Free();
     }
  
  }
  </code></pre>
  
  <p>and every times client try to read stream from the server, compiler says.</p>
  
  <pre><code>First chance exception at $75D89617. Exception class EAccessViolation with message 'Access violation at address 500682B3 in module 'rtl140.bpl'. Read of address 00000018'. Process Project1.exe (6056)
  </code></pre>
  
  <p>How to handle this?</p>