testhst.pp 771 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. program testhst;
  2. uses netdb;
  3. Procedure DumpHostEntry(Const H : THostEntry);
  4. begin
  5. With H do
  6. begin
  7. Writeln('Name : ',Name);
  8. Writeln('Addr : ',HostAddrToStr(Addr));
  9. Writeln('Aliases : ',Aliases);
  10. Writeln;
  11. end;
  12. end;
  13. Procedure TestAddr(Addr : string);
  14. Var
  15. H : THostEntry;
  16. begin
  17. If GetHostByAddr(StrToHostAddr(Addr),H) then
  18. DumpHostEntry(H)
  19. else
  20. Writeln('No entry for address ',Addr)
  21. end;
  22. Procedure TestName(Const N : string);
  23. Var
  24. H : THostEntry;
  25. begin
  26. If GetHostByName(N,H) then
  27. DumpHostEntry(H)
  28. else
  29. Writeln('No entry for hostname ',N)
  30. end;
  31. begin
  32. testaddr('127.0.0.1');
  33. testaddr('212.224.143.213');
  34. testname('LOCALHOST');
  35. testname('www.freepascal.org');
  36. testname('obelix.wisa.be');
  37. end.