testsvc.pp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2003 by the Free Pascal development team
  4. test netdb unit, services part
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. program testsvc;
  12. uses netdb,sockets;
  13. Procedure DumpServiceEntry(Const E : TserviceEntry);
  14. begin
  15. With E do
  16. begin
  17. Writeln('Name : ',Name);
  18. Writeln('Protocol : ',Protocol);
  19. Writeln('Port : ',Port);
  20. Writeln('Aliases : ',Aliases);
  21. Writeln;
  22. end;
  23. end;
  24. Procedure TestPort(P : Word; Const Proto : string);
  25. Var
  26. E : TServiceEntry;
  27. begin
  28. If GetServiceByPort(P,Proto,E) then
  29. DumpServiceEntry(E)
  30. else
  31. Writeln('No entry for port ',P)
  32. end;
  33. Procedure TestName(Const N,Proto : string);
  34. Var
  35. E : TServiceEntry;
  36. begin
  37. If GetServiceByName(N,Proto,E) then
  38. DumpServiceEntry(E)
  39. else
  40. Writeln('No entry for service ',N)
  41. end;
  42. begin
  43. testport(80,'tcp');
  44. testport(25,'');
  45. testport(23,'');
  46. testport(53,'udp');
  47. testname('mail','');
  48. testname('ftp','');
  49. testname('domain','udp');
  50. end.