title: Send and Receive Stream with TidTCPClient and TidTCPServer in Delphi XE2
body: <p>In Delphi XE2 I have a record type with the following structure :</p>
  
  <pre><code>  TMachinInfoRec = record
      IPStr: string[15];
      Username: string[50];
      Computername: string[100];
      SentTime: TDateTime;
      HasCommand: integer; 
      ClientCommands: array[0..9] of TMachineCommand;
    end;
  </code></pre>
  
  <p>I define a variable on its and TMemoryStream variable on the Client side and send stream with TidTCPClient component:</p>
  
  <pre><code>var
    MIRec: TMachinInfoRec;
    msRecInfo: TMemoryStream;
  
  begin
    MIRec.IPStr = '192.168.100.101';
    MIRec.Username := 'user-a';
    MIRec.Computername := 'Computer-a';
    MIRec.SentTime := Now();
  
    idTCPClient.Host := '192.168.100.138';
    idTCPClient.Port := 6000;
  
    idTCPClient.Connect;
  
    msRecInfo := TMemoryStream.Create;
    msRecInfo.Write(msRecInfo, SizeOf(Client));
  
    msRecInfo.Position := 0;
    idTCPClient.IOHandler.Write(msRecInfo);
  end;
  </code></pre>
  
  <p>and And get information on the server side with TidTCPServer : </p>
  
  <pre><code>procedure TFrmMainServer.TCPServerExecute(AContext: TIdContext);
  var
    MIRec: TMachinInfoRec;
    msRecInfo: TMemoryStream;
  begin
    msRecInfo:= TMemoryStream.Create;
  
    AContext.Connection.IOHandler.ReadStream(msRecInfo, SizeOf(MIRec));
  
    msRecInfo.Read(msRecInfo, sizeOf(MIRec));
  
    ShowMessage(MIRec.IPStr);
    ShowMessage(MIRec.Computername)
  end;
  </code></pre>
  
  <p>But a string that is displayed in this format:</p>
  
  <blockquote>
    <p>MZ?.........yy..,.......@...................................,....</p>
  </blockquote>
  
  <p>how can I solve this problem?</p>