SimpleIPC - should it work ? lazarus / 32-Linux ---------------------------------------------------------------------- dbannon · 2019-12-07 01:55 Hi Folks, I have been playing with the two SimpleIPC components on the Lazarus System Tab without any success. In its simplest form, here is what I am doing - Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormShow(Sender: TObject);begin    SimpleIPCClient1.ServerID:='tomboy-ng';    SimpleIPCServer1.ServerID:='tomboy-ng';    if SimpleIPCClient1.ServerRunning then begin        Label1.Caption := 'I am a client';        SimpleIPCClient1.Active := true;        SimpleIPCClient1.SendStringMessage('SHOWSEARCH');    end else begin      Label1.Caption := 'I am a server';        SimpleIPCServer1.Global:=True;                  // anyone can connect        SimpleIPCServer1.Active := true;                // start listening    end;end;                   procedure TForm1.SimpleIPCServer1Message(Sender: TObject);begin    SimpleIPCServer1.ReadMessage;    Label1.Caption := SimpleIPCServer1.StringMessage;end;           I have used the Object Inspector to create the event. Running two instances, the first becomes the 'server' and the second becomes the 'client'. The client sends a message to the server. In practice, the client does recognise that there is a server present, good, and apparently sends it's message but the Server never responds. Have I missed something ?  Documentation is a bit sparse but seems to indicate thats all I need.  I am wondering if more modern forms of Linux block what ever communication channel these components use ? Likely given our interests in security. I can do the same thing with DBus (only on linux) but it seems overkill if this simple approach does work. I have attached my minimalist project. Davo ---------------------------------------------------------------------- winni · 2019-12-07 02:07 Hi! Do you know the github demo page? https://github.com/z505/SimpleIPC-lib/tree/master/demo-lazarus Winni ---------------------------------------------------------------------- dsiders · 2019-12-07 02:11 Quote from: dbannon on December 07, 2019, 02:55:22 amHi Folks, I have been playing with the two SimpleIPC components on the Lazarus System Tab without any success. In its simplest form, here is what I am doing - Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormShow(Sender: TObject);begin    SimpleIPCClient1.ServerID:='tomboy-ng';    SimpleIPCServer1.ServerID:='tomboy-ng';    if SimpleIPCClient1.ServerRunning then begin        Label1.Caption := 'I am a client';        SimpleIPCClient1.Active := true;        SimpleIPCClient1.SendStringMessage('SHOWSEARCH');    end else begin      Label1.Caption := 'I am a server';        SimpleIPCServer1.Global:=True;                  // anyone can connect        SimpleIPCServer1.Active := true;                // start listening    end;end;                   procedure TForm1.SimpleIPCServer1Message(Sender: TObject);begin    SimpleIPCServer1.ReadMessage;    Label1.Caption := SimpleIPCServer1.StringMessage;end;           I have used the Object Inspector to create the event. Running two instances, the first becomes the 'server' and the second becomes the 'client'. The client sends a message to the server. In practice, the client does recognise that there is a server present, good, and apparently sends it's message but the Server never responds. Have I missed something ?  Documentation is a bit sparse but seems to indicate thats all I need.  I am wondering if more modern forms of Linux block what ever communication channel these components use ? Likely given our interests in security. I can do the same thing with DBus (only on linux) but it seems overkill if this simple approach does work. I have attached my minimalist project. Davo Both client and server are used in units in: components/chmhelp/lhelp/ tools/debugserver/ Should give a good representation of their usage. ---------------------------------------------------------------------- dbannon · 2019-12-07 02:53 Quote from: winni on December 07, 2019, 03:07:47 am... Do you know the github demo page? ..... Thanks winin, no, did not know about it.   But they do not compile. The client is an easy fix but the server seems to need something not there. But maybe a look over the code will help. @dsiders, also a good suggestion. If its used in lhelp, must still be usable. I'll have a good poke around in there. Thanks. Davo ---------------------------------------------------------------------- dbannon · 2019-12-07 08:05 OK, this does work as expected - Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.MessageQueued(Sender : TObject);begin    SimpleIPCServer1.ReadMessage;    Label1.Caption := SimpleIPCServer1.StringMessage;end; procedure TForm1.FormShow(Sender: TObject);begin    SimpleIPCClient1.ServerID:='tomboy-ng';    SimpleIPCServer1.ServerID:='tomboy-ng';    if SimpleIPCClient1.ServerRunning then begin        Label1.Caption := 'I am a client';        SimpleIPCClient1.Active := true;        SimpleIPCClient1.SendStringMessage('SHOWSEARCH');        SimpleIPCClient1.Active := false;    end else begin        Label1.Caption := 'I am a server';        SimpleIPCServer1.OnMessageQueued:=@MessageQueued;        SimpleIPCServer1.Global:=True;                  // anyone can connect        //SimpleIPCServer1.Active := true;        SimpleIPCServer1.StartServer(True);             // start listening, threaded    end;end;                   Note two changes from my first attempt - * To start the server we call 'StartServer', setting it to Active is not the same thing ! * Don't use the Object Inspector to set a call back function. Just pass SimpleIPCServer1.OnMessageQueued the address of the function you want to call. I have no idea why ..... Thanks folks for pointing me in right direction. The demos in the fpc source was particularly helpful, in my case /usr/share/fpcsrc/3.0.4/packages/fcl-process/examples Davo