Indy 9
|
TIdIcmpClient = class(TIdRawClient)
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.
property Host: string;
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.
property Port: Integer;
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.
property Protocol: Integer;
property ReceiveTimeout: integer;
property ReplyData: string;
property ReplyStatus: TReplyStatus;
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:
constructor Create(AOwner: TComponent); override;
procedure Ping(ABuffer: String = ''; SequenceID: word = 0);
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.
function Receive(ATimeOut: Integer): TReplyStatus;
property OnReply: TOnReplyEvent;