Indy 9
TIdIcmpClient
Hierarchy, Properties, Methods, Events, See Also, Unit: IdIcmpClient
TIdIcmpClient = class(TIdRawClient)
Unit
IdIcmpClient
Description
TIdIcmpClient is a Internet Protocol client implementation based on the Internet standards document, RFC 792 - Internet Control Message Protocol (http://www.rfc-editor.org/rfc/rfc792.txt) , .

TIdIcmpClient is used to send an Internet Control Message Protocol (ICMP) packet to another computer. ICMP packets are used for ping and TraceRoute capability to help diagnose problems with connectivity.

TIdIcmpClient is a descendant of the abstract class TIdRawClient, and uses the Protocol value Id_IPPROTO_ICMP (Decimal 1). TIdIcmpClient uses the message formats and algorithms as defined in RFC 792.

Use TIdIcmpClient to diagnose a communications links by using Ping. Host identifies the IP address or computer name for the echo request. Use ReplyStatus and OnReply to access information received as a result of the echo request datagram. Set ReceiveTimeout to control the time to wait for a response to the echo request datagram.

Use the TTL property to set the packet's Time To Live value: the maximum number of hops the packet will travel before being bounced.

For Traceroute application, send ping echo requests with increased TTL values. Each reply will hold the IP address of the hop where the TTL expired, allowing the program to build the packet's route.

Note: For Windows NT, and Windows 2000, administrator privileges are required to allow TIdICMPClient.Ping to work properly. The command line PING application does not exhibit this behavior because Microsoft chose to use undocumented calls in ICMP.DLL and its winsock implementation to get around the issue. In short: they cheated. Indy does not use ICMP.DLL to maintain Linux compatibility, and allow use of both Raw sockets and ICMP sockets.


TIdIcmpClient.Host
TIdIcmpClient, See Also
Specifies the address used to connect to a computer.
property Host: string;
Description
Host identifies the address used to connect to a computer. The address can be a computer name such as "wvnvm.wvnet.edu" or an IP address such as "129.71.2.4".

To connect to a server on your machine, use IP address "127.0.0.1" aka [localhost].

Use Port to specify the port number used for the connection.


TIdIcmpClient.Port
TIdIcmpClient, See Also
Specifies the port number used by the local connection.
property Port: Integer;
Description
Port is an Integer property that identifies the port number on the local system where data is sent and received.

Note: Many port numbers are associated, by convention, with a particular service such as ftp or http as described in IdPorts. Some protocols use pre-defined port numbers. Port numbers below 1024 are reserved, but using a number above 1024 does not guarantee there will be no conflict.


TIdIcmpClient.Protocol
TIdIcmpClient, See Also
Specifies the ICMP Internet Protocol for the socket connection.
property Protocol: Integer;
Description
Protocol identifies the Internet Protocol used by the socket connection. TIdIcmpClient uses the value Id_IPPROTO_ICMP as defined in IdStackConst.pas. The default value of Protocol is assigned in the Create constructor. Do not change the value of Protocol, or the communications link may not function properly.

TIdIcmpClient.ReceiveTimeout
TIdIcmpClient, See Also
Specifies the time limit to wait for echo responses.
property ReceiveTimeout: integer;
Description
ReceiveTimeout is an Integer property that identifies the maximum time that a socket connection should wait for a response to an echo request. ReceiveTimeout is specified in milliseconds.

ReceiveTimeout is used when capturing an echo request in Ping.


TIdIcmpClient.ReplyData
TIdIcmpClient, See Also
Represents the raw data in the ICMP Echo reponse.
property ReplyData: string;
Description
ReplyData is a read-only String property that represents the values received in an ICMP Echo response. ReplyData is updated when the ICMP response packet contains types Id_ICMP_ECHOREPLY or Id_ICMP_ECHO, and consists of the raw response packet following the IP and ICMP headers. ReplyData does not have any significance when the ICMP reponse type is any value other than Id_ICMP_ECHOREPLY or Id_ICMP_ECHO.

TIdIcmpClient.ReplyStatus
TIdIcmpClient, See Also
Specifies the structure used to store a response to an echo request.
property ReplyStatus: TReplyStatus;
Description
ReplyStatus is a TReplyStatus property used to store a response to an echo request.

ReplyStatus is updated when a receiving a response to an echo request in Ping. When the response to an echo request contains a non-zero length, ReplyStatus is updated with the contents of the echo response datagram.

When the response to an echo request contains 0 bytes, ReplyStatus is updated with values to indicate the error condition, including:

  • BytesReceived - 0

  • FromIpAddress - '0.0.0.0'

  • MsgType - 0

  • SequenceId - Internal sequence number from TIdIcmpClient

  • TimeToLive - 0

  • ReplyStatusType - rsTimeOut

TIdIcmpClient.Create
TIdIcmpClient, See Also
Constructor for the object instance.
constructor Create(AOwner: TComponent); override;
Description
Create is the constructor for the object instance. Create relies on the inherited Create constructor to initialize the object instance. In the constructor, Protocol is set to the value Id_IPPROTO_ICMP defined in IdStackConst.pas, and the internal packet sequence number is set to 0.

TIdIcmpClient.Ping
TIdIcmpClient, See Also
Sends an echo request and receives an echo response.
procedure Ping(ABuffer: String = ''; SequenceID: word = 0);
Description
Ping is used to prepare and send and echo request, and to receive the echo response. Ping sends the echo request to the computer identified in Host, and gets the response to the echo request datagram.

Set ReceiveTimeout to indicate the time to wait for a response to the echo request datagram.

Use ReplyStatus to access the TReplyStatus received as a response to the echo request datagram.

Assign an OnReply event handler to perform additional processing when a TOnReplyEvent is detected.

TIdIcmpClient closes the socket handle allocated on completion of the Ping method.

Note: For Windows NT, and Windows 2000, administrator privileges are required to allow TIdICMPClient.Ping to work properly. The command line PING application does not exhibit this behavior because Microsoft chose to use undocumented calls in ICMP.DLL and its winsock implementation to get around the issue. In short: they cheated. Indy does not use ICMP.DLL to maintain Linux compatibility, and allow use of both Raw sockets and ICMP sockets.


TIdIcmpClient.Receive
TIdIcmpClient, See Also
Reads data from the protocol stack.
function Receive(ATimeOut: Integer): TReplyStatus;
Parameters
ATimeOut: Integer
Timeout value in milliseconds.
Return Value
TReplyStatus - Response type for the echo request.
Description
Receive is a TReplyStatus function that reads data from the receive buffer for the ICMP broadcast. Receive fills the entire receive buffer with the value CHAR0 and calls ReceiveBuffer to read the required number of bytes into the allocated buffer. Receive calls CheckForSocketError to insure that a socket error did not occur during data receipt. Receive calls DecodeResponse to store received data in the TReplyStatus returned from the method.

TIdIcmpClient.OnReply
TIdIcmpClient, See Also
Specifies an event handler for TOnReplyEvent events.
property OnReply: TOnReplyEvent;
Parameters
ReplyStatus
TReplyStatus Reply from the echo request.
Description
OnReply is a TOnReplyEvent handler triggered when a echo response is received. OnReply is generally used to update progress indicators or other GUI components as a result of receiving the echo response found in ReplyStatus. Assign an event handler to perform additional processing when the TOnReplyEvent is triggered by Ping.

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