Recommendation for a simple ip client server setup lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Josh · 2019-02-19 16:41 Hi I have been experimenting with IPCSimple server, and this does very well as long as its on same PC. I would like to know what others would suggest for a local network scenario, where the client app sends commands to the server app ( on different local PC) . Needs to be x-platform; preferrably without any libraries.  All that wuld be sent is Text Message, no requirement for any server side scripting engines. It would be nice if the server could be found by the client, for when DHCP is used to issue IP. Actual Protocol used is not that important; as long as the protocol is native to all OS's. Thnx in advance Josh ---------------------------------------------------------------------- lucamar · 2019-02-19 18:39 For a simple client/server scenario? Use FPHTTPServer:and FPHTTPClient (from the package fcl-web). There is some documentation in the wiki, IIRC. later: Yep, here it is: fcl-web but it lacks info on the simple client/server objects ---------------------------------------------------------------------- Josh · 2019-02-20 01:04 Hi I experimented with fcl-web, but got no where very fast. SO I tried indy. When I place a IdTCPServer on form, set it parameters etc. When run windows, it works fine. Running the same on OSX gives error Threading has been used before cthreads was inititalised. I have ctthreads as the first unit in uses clause. Is this a known bug, with OSX? ---------------------------------------------------------------------- dsiders · 2019-02-20 01:59 Quote from: josh on February 20, 2019, 02:04:22 amHi I experimented with fcl-web, but got no where very fast. SO I tried indy. When I place a IdTCPServer on form, set it parameters etc. When run windows, it works fine. Running the same on OSX gives error Threading has been used before cthreads was inititalised. I have ctthreads as the first unit in uses clause. Is this a known bug, with OSX? Not a Mac guy, so... Did you use cthreads or ctthreads? ctthreads would be a typo and should have had a different error. But using cthreads is required for any non-Windows environment since Indy uses threads in the server. If its not the main unit in the project, you can also try using the -dUseCThreads define in the Compiler Options for your project. ---------------------------------------------------------------------- Josh · 2019-02-20 07:33 hi just typo.. the app compiles, but will not run code below. 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 unit serverunit1; {$mode objfpc}{$H+} interface uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, IdTCPServer,  IdContext, IdCustomTCPServer; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    IdTCPServer1: TIdTCPServer;    Memo1: TMemo;    procedure Button1Click(Sender: TObject);    procedure IdTCPServer1Execute(AContext: TIdContext);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);var srec:string;begin  srec:=Acontext.Connection.IOHandler.readln;  memo1.Lines.Add(srec);end; procedure TForm1.Button1Click(Sender: TObject);begin  IdTCPServer1.Active:=true;end; end. ---------------------------------------------------------------------- Thaddy · 2019-02-20 09:01 Can you explain why fcl-web/net didn't work? Because things like synapse and Indy are ok, but not your original intention. If I know why, I can write a simple example. ---------------------------------------------------------------------- Josh · 2019-02-20 12:23 Hi Thaddy, When I was trying FCL-WEB/Net, i was getting various errors, even some of the examples would not compile ( using latest trunk ). I suspect most of the errors I was getting were down to not knowing exactly how the components worked, mainly lack of documentation that I could not find. When I tried Indy, a lot more examples were available; and most worked straight off which were deigned for Indy 10. I would however prefer to use FCL_WEB/NET as its part of the FPC/LAazarus Components. What I trying to do is a similar to what IPCServer does but using TCP to allow communication over a network. ie Server side listening on a port  Ip number can change. Client sending Text Messages to server, so needs to find server IP I suppose. Total start and shutdown of the client app is inmportant, as the remote control is a console app that just sends a string based on the extra parameters it receives. Word PowerPoint LibreWrite etc, can have macros to run external application which allows a simple and effeccient way to allow changinmg of main applicatioin values. Which SimpleIPC does well, but not suited for a network. for example  remote_control p1 7689 would send command to main application to change P1 to 7689 I hope that make sense. Josh ---------------------------------------------------------------------- Remy Lebeau · 2019-02-21 21:53 Quote from: josh on February 20, 2019, 08:33:22 amthe app compiles, but will not run In what way exactly? Quote from: josh on February 20, 2019, 08:33:22 amcode below. The only thing I see wrong is your OnExecute event handler is not syncing with the main UI thread when accessing the TMemo.  TIdTCPServer is a multi-threaded components, its events are fired in the context of worker threads.  So, you can't access your TMemo directly since IdTCPServer1Execute() is run outside of the UI thread, so you need to sync access to the TMemo, such as with TThread.Synchronize() or TThread.Queue(), or Indy's TIdSync or TIdNotify. ---------------------------------------------------------------------- Josh · 2019-02-22 09:58 Hi Remy, QuoteIn what way exactly? If I try to run the bundle, I do not even see the GUI, it just terminates. If I run the executable, so that I can see the console, and error generted This is where the message is shown QuoteThreading has been used before cthreads was inititalised.Cthreads is the first in the uses clause, compiler option -dUseCThreads is also set. The button to activate the IdTCPServer1 is on the form, so the server should not be running. ---------------------------------------------------------------------- Cyrax · 2019-02-22 12:59 Quote from: josh on February 22, 2019, 10:58:51 amHi Remy, QuoteIn what way exactly? If I try to run the bundle, I do not even see the GUI, it just terminates. If I run the executable, so that I can see the console, and error generted This is where the message is shown QuoteThreading has been used before cthreads was inititalised.Cthreads is the first in the uses clause, compiler option -dUseCThreads is also set. The button to activate the IdTCPServer1 is on the form, so the server should not be running. Try to move cthreads unit in to main program uses clause (the .lpr file).