Witam serdecznie juz kiedys pisalem podobny post niestety nie uzyskalem odpowiedzi. Program ma sprawdzac predkosc odpowiedzi danego serwera dns na zadana domene. Poprawilem nieco kod cos tam juz dziala ale nie do konca ... otoz jest taki problem iz np serwer dns netii odpowiada prawidlowo a tp sie sypie ... moze wy dojdziecie do tego co jest nie tak:
procedure TfmMain.tbStartClick(Sender: TObject);
var
i, k, j, z: Integer;
arDomain, arDNS : array of Double;
begin
Application.ProcessMessages;
Screen.Cursor := crHourGlass;
SetLength(arDomain,3);
SetLength(arDNS,domainList.Count);
if tbStart.Caption = 'Start' then
begin
try
tbStart.Caption := 'Stop';
for i := 0 to dnsList.Count - 1 do //lista serwerow dns zdeklarowana wczesniej
begin
for j := 0 to domainList.Count - 1 do // lista domen j.w.
begin
for k := 0 to 2 do // ilosc testow do wykonania
begin
if zatrzymaj then
Exit;
arDomain[k] := dnsresp(dnsList[i],domainList[j]); // glowny engin programu
end;
//ponizej pierdolki do wyswietlania itd :) malo wazne
tmp := 0;
for z := 0 to Length(arDomain) - 1 do
tmp := tmp + arDomain[z];
tmp := Floor(tmp / 3);
sgdDomain.Cells[2,j+1] := FloatToStr(tmp);
arDNS[j] := tmp;
end;
for z := 0 to Length(arDNS) - 1 do
tmp := tmp + arDNS[z];
tmp := Floor(tmp / Length(arDNS));
sgdDNS.Cells[2,i+1] := FloatToStr(tmp);
end;
finally
tbStart.Enabled := True;
tbStart.Caption := 'Start';
Screen.Cursor := crDefault;
end;
end
else
begin
tbStart.Caption := 'Start';
zatrzymaj := True;
Screen.Cursor := crDefault;
Exit;
end;
end;
function TfmMain.dnsresp(host, domena: string): Cardinal;
var
i: Integer;
Freq, TimeStart, TimeEnd : Int64;
begin
Application.ProcessMessages;
DNS.Host := host;
try
try
//ten kod jest z jednego sampla ja go tylko przebudowalem pod moje potrzeby niestety nie dziala jak powinien ... :/
DNS.QueryResult.Clear;
DNS.QueryType := [qtSTAR];
DNS.Resolve(domena);
if QueryPerformanceFrequency(Freq) then //tu mierzymy czas (jak macie inny pomysl to pisac)
begin
QueryPerformanceCounter(TimeStart);
for I := 0 to DNS.QueryResult.Count-1 do
begin
case DNS.QueryResult.Items[1].RecType of
qtA:
begin
memReply.Lines.Add('A:');
memReply.Lines.Add(' '+TARecord(DNS.QueryResult.Items[I]).IPAddress);
end;
end;
end;
QueryPerformanceCounter(TimeEnd);
Result := Floor((TimeEnd-TimeStart)/Freq*1000);
end;
except
on E: Exception do
memReply.Lines.Text := memReply.Lines.Text + E.Message;
Result := 2000;
end;
finally
end;
end;