Senai
Senai

Reputation: 15

IdTCPClient is very slow with large StringStream

Recently we added base64 encoded pdf file to an HL7 message as a last OBX segment which added 2.5MB to the message (which was only 2kb). That caused tremendous slowing of TCPClient write speed and takes more than 40 seconds.

procedure TfrmHL7.SendComposedHL7Message(HL7Msg: string);
var 
  ms         : TStringStream;
begin
 
  ms := TStringStream.Create(HL7Msg);  
  try
      ms.Position := 0;
//TStopWatch.Start
    HL7DM.IdHL7TCPClient.IOHandler.Write(ms, 0, True);
//TStopWatch.Stop (result: 41000)
  finally
    ms.Free;
  end;

end;

I tried to inc the buffer size to 65k but that didn't help.

Other than sending the PDF file with a different protocol, any guide on how to speed up the TCP writestream is highly appreciated.

Upvotes: 0

Views: 91

Answers (0)

Related Questions