title: Delphi idtcpserver idtcpclient tstringstream to string
body: <p>I try to send a string from a tidtcpserver to a tidtcpclient in Delphi, but when i send a string the client receives nothing. I don't get any errors. I am using tstringstream because i want to send a base64 string(writeln/readln can't send/receive that much text)
  This is the send code in idtcpserver1:</p>
  
  <pre><code>procedure TForm1.sendtext(index:integer; txt:string);
  var
    StrStream:tStream;
    List: TList;
    AContext: TIdContext;
  begin
    txt := trim(txt);
    strstream := TMemoryStream.Create;
    strstream.Write(PAnsiChar(txt)^, Length(txt));
    strstream.Position := 0;
    List := idTcpServer1.Contexts.LockList;
    AContext := TIdContext(List[index]);
    AContext.Connection.IOHandler.write(StrStream);
    idTcpServer1.Contexts.UnLockList;
  end;
  </code></pre>
  
  <p>This is the read code in idtcpclient1</p>
  
  <pre><code>procedure TIndyClient.Execute;
  var
  StrStream:tStringStream;
  receivedtext:string;
  begin
  StrStream := tstringstream.Create;
  form1.IdTCPClient1.IOHandler.readstream(StrStream);
  receivedtext := strstream.DataString;
  if receivedtext = '' = false then
  begin
    showmessage(receivedtext);
  end;
  end;
  </code></pre>
  
  <p>Does anyone know what i am doing wrong?</p>