private
ActiveIPList, AllIPList: TStringList;
procedure TForm1.FillAllIPList;
begin
// Some way to fill the list with IP's
AllIPList.Add('192.168.0.101');
AllIPList.Add('192.168.0.102');
AllIPList.Add('192.168.0.103');
AllIPList.Add('192.168.0.104');
AllIPList.Add('192.168.0.105');
AllIPList.Add('192.168.0.106');
AllIPList.Add('192.168.0.107');
AllIPList.Add('192.168.0.108');
AllIPList.Add('192.168.0.109');
AllIPList.Add('192.168.0.110');
end;
procedure TForm1.Button1Click(Sender: TObject);
var i: integer;
begin
FillAllIPList;
for i := (AllIPList.Count - 1) downto 0 do
begin
IdICMPClient1.Host := AllIPList.Strings[i];
IdICMPClient1.Port := 80;
IdICMPClient1.ReceiveTimeOut := 500;
IdICMPClient1.Ping();
end;
end;
procedure TForm1.IdIcmpClient1Reply(ASender: TComponent; const AReplyStatus: TReplyStatus);
begin
if (AReplyStatus.ReplyStatusType <> rsTimeOut) and (AReplyStatus.ReplyStatusType <> rsErrorUnreachable) and (AReplyStatus.FromIpAddress <> '0.0.0.0') then
begin
ActiveIPList.Add(AReplyStatus.FromIpAddress);
end;
end;