[fpc-pascal] lnet for TCP daemon

Dennis Poon dennis at avidsoft.com.hk
Thu Sep 12 09:43:09 CEST 2013



Mark Morgan Lloyd wrote:
> Is it feasible to use lnet for a simple TCP daemon on Linux, i.e. wait 
> for a connection on a predefined port, read as much data as is 
> available, repeat? And if so, what does the SerSock parameter to 
> Accept() represent?
>
> I'd normally use a thread for this, but I've already got lnet's telnet 
> client running in the program so would rather stick to the same 
> library if possible.
>

Mark,

I have done that before.

Basically, in Lnet, if you have more than 1 LTcp object, you must create 
your own TEventer and override its CallAction method.

Then assume your Ltcp object is myLTCP
   myLTCP.Eventer := TMyEventer.Create;



In my thread.execute
    repeat
      myLTCP.Eventer.CallAction
   until terminated;


   if you have just one ltcp then just
    repeat
      myLtcp.CallAction
   until terminated


I don't know about SerSock.  Never used it and seemed have no need for it.
Dennis



More information about the fpc-pascal mailing list