testrhre.pp 823 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. {$mode objfpc}
  2. {$h+ }
  3. { test reverse host resolve }
  4. program testrhre;
  5. uses resolve,sysutils,Sockets;
  6. Var
  7. I : integer;
  8. S : String;
  9. begin
  10. If (ParamCount>0) then
  11. S:=Paramstr(1)
  12. else
  13. S:='212.224.143.202';
  14. With THostResolver.Create(Nil) do
  15. try
  16. If Not AddressLookup(S) then
  17. Writeln('Lookup failed : ',LastError)
  18. else
  19. begin
  20. Writeln('Name : ',ResolvedName);
  21. Writeln('Addres : ',AddressAsString);
  22. Writeln('Address count : ',AddressCount);
  23. For I:=0 to AddressCount-1 do
  24. Writeln('Adress ',I:2,' : ',HostAddrToStr(Addresses[I]));
  25. Writeln('Alias count : ',AliasCount);
  26. For I:=0 to AliasCount-1 do
  27. Writeln('Alias ',i:2,' : ',Aliases[I]);
  28. end;
  29. finally
  30. Free;
  31. end;
  32. end.