[Lazarus] lnet component
a.fortuny at sitasoftware.lu
Wed Sep 5 10:01:59 CEST 2012
I'm looking for a solution to the next problem:
I've an application running in both Win32 and WinCE. So far it runs OK
but I run into trouble when I try to control the TCP/IP traffic between
the application and a TCP/IP server running into a Windows box (Delphi
AFAIK the TLTCPComponent (Lazarus lnet package) I use as a TCP client,
runs asynchronously. But in some places I need to control a timeout and
do something special when the TCP link fails on either the connection
phase or the send/receive phase because the internal timeouts are
definitely too long. I didn't see any place to setup a timeout for the
For the moment I've built a loop using a Sleep (50 ms on each loop) and
this is quite boring. I guess than when the main thread enters a Sleep,
everyting in it falls into the same Sleep, TCP inclusive.
Question: how to suspend the application while waiting for either a
connection or a response from the server ? In other words, how to run
lnet in a synchronous way (like Indy does) ?
My own solution tends to use a thread which can run asynchronously and
process event from the socket as they arrive (onConnect, onReceive). The
thread can post a global variable when operation is done. The problrm is
this is a heavy piece of code and tests are not easy. This also means an
application refactory. Looks like Indy is working actually.
Unfortunately, although Indy compiles and works with Lazarus Win32,
Win64 and Linux64, it does not compile for WinCE.
All ideas are welcome.
More information about the Lazarus