testsvc.pp 815 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. program testsvc;
  2. uses netdb;
  3. Procedure DumpServiceEntry(Const E : TserviceEntry);
  4. begin
  5. With E do
  6. begin
  7. Writeln('Name : ',Name);
  8. Writeln('Protocol : ',Protocol);
  9. Writeln('Port : ',Port);
  10. Writeln('Aliases : ',Aliases);
  11. Writeln;
  12. end;
  13. end;
  14. Procedure TestPort(P : Word; Const Proto : string);
  15. Var
  16. E : TServiceEntry;
  17. begin
  18. If GetServiceByPort(P,Proto,E) then
  19. DumpServiceEntry(E)
  20. else
  21. Writeln('No entry for port ',P)
  22. end;
  23. Procedure TestName(Const N,Proto : string);
  24. Var
  25. E : TServiceEntry;
  26. begin
  27. If GetServiceByName(N,Proto,E) then
  28. DumpServiceEntry(E)
  29. else
  30. Writeln('No entry for service ',N)
  31. end;
  32. begin
  33. testport(25,'');
  34. testport(23,'');
  35. testport(53,'udp');
  36. testname('mail','');
  37. testname('ftp','');
  38. testname('domain','udp');
  39. end.