2
votes

I have an application that sends and receives data from a given website with TIdTCPClient - looks like this :

TCPClient.Host := myHost;
TCPClient.Port := myPort;
TCPClient.Connect;
TCPClient.IOHandler.Write(clientRequest);
TCPClient.IOHandler.ReadStream(clientResponse, size, False);

where clientRequest is created dynamically and clientResponse is what the server (the wanted website) sends as a response.So my question is how can I calculate the average response time from the website my TCPClient has connected to ?

1
What is your problem? Measure the time or calculating average?Sir Rufo
If you are talking to a website, why are you using TIdTCPClient and not TIdHTTP?Remy Lebeau
@Remy Like I said in my question - any Indy client would do the job as long as someone provides a solution for calculating the website response time - I just have two applications - one with TIdHTTP and one with TIdTCPClient and provided example code only from one of them.Viktor Anastasov
@SirRufo I will have to write code for both but measuring the time is with bigger priority.Viktor Anastasov
@Roman_Bezjak: nothing in your question mentions "any" Indy client, or the fact that you have another app that uses TIdHTTP.Remy Lebeau

1 Answers

3
votes

Look at Indy's Ticks() and GetTickDiff() functions, for example:

uses
  ..., IdGlobal;

var
  StartTicks: LongWord;
begin
  ...
  StartTicks := Ticks;
  TCPClient.IOHandler.ReadStream(clientResponse, size, False);
  Elapsed := GetTickDiff(StartTicks, Ticks);
  ...
end;