summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/fcl-base/examples/testrsre.pp
blob: 931b5feb7f6a24b63284082f09b79befff23c65a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{$mode objfpc}
{$h+ }

{ test reverse service resolve }

program testrsre;

uses sysutils,resolve;

Var
  I : integer;
  S : longint;
  P : String;


begin
  If (ParamCount>0) then
    S:=StrToIntDef(Paramstr(1),0)
  else
    S:=23;
  If (ParamCount>1) then
    P:=Paramstr(2)
  else
    P:='';
  With TServiceResolver.Create(Nil) do
    try
      If Not PortLookup(S,P) then
        Writeln('Lookup failed : ',LastError)
      else
        begin
        Writeln('Name          : ',ResolvedName);
        Writeln('Protocol      : ',Protocol);
        Writeln('Port          : ',port);
        Writeln('Aliases       : ',AliasCount);
        For I:=0 to AliasCount-1 do
          Writeln('Alias ',i:2,'  : ',Aliases[I]);
        end;
    finally
      Free;
    end;
end.