Starting with KBMMW 5.01, Delphi 10.2 and Linux were officially supported.
Today we're going to build a KBMMW for Linux server simply say it.
This example is based on the last Linux daemon example.
If you are unfamiliar, please read the above article first.
First, put Kbmmwserver and Kbmmwtcpipindyservertransport inside the datamodule.
Two of controls.
, and set the corresponding value.
Then set up a standard service that can be referenced in this example.
Generate the corresponding services and functions.
Add the code to build the service in Datamodule.
procedure tdmf.datamodulecreate (sender:tobject); var sd:tkbmmwcustomservicedefinition; begin SD:=kbmmwserver1.registerservice (tkbmmwinventoryservice,false); SD:=kbmmwserver1.registerservice (txalionsrv,false); End;
The main program code is as follows:
ProgramProject2;{$APPTYPE CONSOLE}{$R *.res}usesposix.unistd, Posix.systypes, System.sysutils, DMPinch 'Dmp.pas' {Dmf:tdatamodule}, Srv_ywinch 'Srv_yw.pas' {Xalionsrv:tkbmmwsimpleservice};procedureDaemon;beginDMF:=TDMF.Create(Nil); Dmf.kbmmwserver1.Active:=True; Writeln ('Service started'); Try RepeatSleep (Ten* +); untilFalse; finallyDMF. Free; End;End;varpid:pid_t;beginPID:=Fork; ifPID =0 Then beginWriteln ('Starting service'); Daemon End;End.
Compile and run the program under Linux.
After the program exits, it automatically establishes a service in the background.
Well, we access this program on the client.
There seems to be no problem, it's so easy to write Linux servers with KBMMW.
Do you like it?
First KBMMW for Linux server