testhst.pp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2003 by the Free Pascal development team
  5. test netdb unit, hosts part.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. program testhst;
  13. uses netdb;
  14. Procedure DumpHostEntry(Const H : THostEntry);
  15. begin
  16. With H do
  17. begin
  18. Writeln('Name : ',Name);
  19. Writeln('Addr : ',HostAddrToStr(Addr));
  20. Writeln('Aliases : ',Aliases);
  21. Writeln;
  22. end;
  23. end;
  24. Procedure TestAddr(Addr : string);
  25. Var
  26. H : THostEntry;
  27. begin
  28. If GetHostByAddr(StrToHostAddr(Addr),H) then
  29. DumpHostEntry(H)
  30. else
  31. Writeln('No entry for address ',Addr)
  32. end;
  33. Procedure TestName(Const N : string);
  34. Var
  35. H : THostEntry;
  36. begin
  37. If GetHostByName(N,H) then
  38. DumpHostEntry(H)
  39. else
  40. Writeln('No entry for hostname ',N)
  41. end;
  42. begin
  43. testaddr('127.0.0.1');
  44. testaddr('212.224.143.213');
  45. testname('LOCALHOST');
  46. testname('www.freepascal.org');
  47. testname('obelix.wisa.be');
  48. end.
  49. {
  50. $Log$
  51. Revision 1.2 2003-05-17 20:54:03 michael
  52. + uriparser unit added. Header/Footer blocks added
  53. }