Delphi Ping

2021-03-06 13:28

阅读:532

标签:pcl   receive   try   time   integer   exce   res   func   cli   

function PingServer(HostIP: string;LinkTimeOut: integer): boolean;
var
  RRemoteC: TIdIcmpClient;
  AReplyStatus: TReplyStatus;
begin
  try
    result := true;
    RRemoteC := TIdIcmpClient.Create(nil);
    RRemoteC.Host := HostIP;
    RRemoteC.ReceiveTimeout := LinkTimeOut;
    try
      RRemoteC.Ping;
      AReplyStatus := RRemoteC.ReplyStatus;
      if (AReplyStatus.ReplyStatusType = rsTimeOut) then
      begin
        result := false;
      end;
    except
      result := false;
    end;
  finally
    RRemoteC.Free;
  end;
end;

  

Delphi Ping

标签:pcl   receive   try   time   integer   exce   res   func   cli   

原文地址:https://www.cnblogs.com/CipherLab/p/12862720.html


评论


亲,登录后才可以留言!