Indy 9
TIdEcho
Hierarchy, Properties, Methods, Events, See Also, Unit: IdEcho
Implements an Echo client.
TIdEcho = class(TIdTCPClient)
Unit
IdEcho
Description
TIdEcho implements the TCP-based variant of the Echo Protocol as described in the Internet Standards document RFC 862 - Echo Protocol (http://www.rfc-editor.org/rfc/rfc862.txt) .

TIdEcho is a TIdTCPClient descendant that is a useful debugging and measurement protocol where the data sent to the server is simply sent back to the originating client. TIdEcho is provided as a measure of the time it takes to send and receive data from an Echo Server (TIdECHOServer).

The TCP-based implementation of the Echo Protocol is a connection based application. An Echo Server listens for TCP connections on TCP Port 7. When a connection is established, any received data is returned to the originating client. The connection continues until the client application closes the connection.

To use TIdEcho, perform the following actions in your application:

  • Call Connect to connect to the Echo Server.

  • Call Echo to send data to the server and receive the server response.

  • Use EchoTime to retrieve the number of milliseconds needed to send and receive data from the server.

  • Call Disconnect to close the connection to the server.

TIdEcho.EchoTime
TIdEcho, See Also
Indicates the elapsed time needed to send and receive echo data.
property EchoTime: Cardinal;
Description
EchoTime is a Cardinal property that indicates the number of milliseconds required to send and receive data using the Echo method. Use EchoTime to determine when there may be problems with the network or connection.

EchoTime is calculated using GetTickDiff, from IdGlobal.pas, and represents the elapsed milliseconds from the start of the echo request until completion of the echo response. EchoTime is adjusted to reflect situations where the elapsed time reverts to a 0 (zero) value after the Echo transmission has been started.


TIdEcho.Port
TIdEcho, See Also
Port number for the ECHO protocol.
property Port: integer;
Description
Port is an Integer property that represents the port number used by the ECHO protocol. Port is redefined in TIdEcho to establish the default port number for the protocol (IdPORT_ECHO). The default value for Port is assigned in the Create constructor.

TIdEcho.Create
TIdEcho, See Also
Creates a TIdEcho instance.
constructor Create(AOwner: TComponent); override;
Parameters
AOwner: TComponent
Owner of the object instance.
Description
Create constructs a properly initialized instance of TIdEcho using the inherited Create constructor, and initializes Port to the constant value IdPORT_ECHO (Decimal 7) as required by the Echo Protocol.

An application must initialize Host and call Connect prior to sending data using the Echo method. Call Disconnect prior to freeing the object instance.


TIdEcho.Echo
TIdEcho, See Also
Sends and receives echo data.
function Echo(AText: String): String;
Parameters
AText: String
Data to send to the echo server.
Return Value
String - Data received from the echo server.
Description
Echo is a String function that sends the text in AText to the echo server, and returns the text received from the echo server. If the returned value is not the same as the text in AText, there may be a problem with the server or the TCP connection.

Echo monitors the time needed to send the echo request and receive the echo response, and stores the elapsed time in EchoTime. Echo uses GetTickDiff, from IdGlobal.pas, to retrieve both the starting and ending milliseconds measurements used to determine EchoTime. Echo can account for the elapsed time reverting to a 0 (zero) value after starting the Echo transmission.


Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.