summaryrefslogtreecommitdiff
path: root/packages/fcl-process/examples/ipcclient.pp
blob: 595878e81303abbd5daa3e9058f65ec85c216911 (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
{$mode objfpc}
{$h+}
program ipcclient;

uses sysutils,simpleipc;

Var
  I,Count : Integer;
  DoStop : Boolean;

begin
  Count:=1;
  With TSimpleIPCClient.Create(Nil) do
    try
      ServerID:='ipcserver';
      If (ParamCount>0) then
        begin
        DoStop:=(ParamStr(1)='-s') or (paramstr(1)='--stop');
        if DoStop then
          ServerInstance:=Paramstr(2)
        else  
          ServerInstance:=Paramstr(1);
        if (Not DoStop) and (ParamCount>1) then
          Count:=StrToIntDef(ParamStr(2),1);  
        end;  
      Active:=True;
      if DoStop then
        SendStringMessage('stop')
      else  for I:=1 to Count do
        SendStringMessage(Format('Testmessage %d from client',[i]));
      Active:=False;
    finally
      Free;
    end;
end.