PingIP地址

IdIcmpClient1: TIdIcmpClient; 



 IdIcmpClient1.Host:='192.168.0.99';

  IdIcmpClient1.Ping('cccc');



procedure TForm1.IdIcmpClient1Reply(ASender: TComponent;

  const AReplyStatus: TReplyStatus);

var

  sTime:string;

begin

if (AReplyStatus.MsRoundTripTime = 0) then

    sTime := '<1'

else

    sTime := '=';



  Memo1.Lines.add(Format('%d bytes from %s: icmp_seq=%d ttl=%d time%s%d ms',

    [AReplyStatus.BytesReceived,

    AReplyStatus.FromIpAddress,

    AReplyStatus.SequenceId,

    AReplyStatus.TimeToLive,

    sTime,

    AReplyStatus.MsRoundTripTime]));

  case AReplyStatus.ReplyStatusType of

    rsEcho: Memo1.Lines.add('远程服务器良好,可以开始传送。');

    rsError: Memo1.Lines.add('收到错误的回应信息,网络状况有问题。');

    rsTimeOut: Memo1.Lines.add('服务器没有响应,超时了。');

    rsErrorUnreachable:Memo1.Lines.add('错误的地址。') ;

    rsErrorTTLExceeded: Memo1.Lines.add('TTL响应超时,网络状况很不好,建议不要传送。');

    rsErrorPacketTooBig: ;

    rsErrorParameter: ;

    rsErrorDatagramConversion: ;

    rsErrorSecurityFailure: ;

    rsSourceQuench: ;

    rsRedirect: ;

    rsTimeStamp: ;

    rsInfoRequest: ;

    rsAddressMaskRequest: ;

    rsTraceRoute: ;

    rsMobileHostReg: ;

    rsMobileHostRedir: ;

    rsIPv6WhereAreYou: ;

    rsIPv6IAmHere: ;

    rsSKIP: ;

    else

      Memo1.Lines.add('其它未知错误。');

  end;

  Memo1.Lines.Add('');

  Application.ProcessMessages;

end;

 

你可能感兴趣的:(ping)