On Wednesday 23 September 2015 06:33:02 Bo Berglund wrote: > On Tue, 22 Sep 2015 10:00:12 +0200, Michael Schnell > > <[email protected]> wrote: > >On 09/21/2015 04:42 PM, Bo Berglund wrote: > >> Unfortunately since the existing code is built on non-blocking serial > >> communications and events to handle the data reception ... > > > >You can convert a blocking socket (or serial port receive) to be a > >non-blocking Event-triggering (i.e. Delphi-Paradigm based) code by > >encapsulating the blocking API in a thread and fire an event to the main > >threads by TThread.Synchronize, TThread.Queue or > >Application.QueueAsyncCall. Now you can do the complex work in the main > >Thread event. > > That is what I figured I could do with the TInetSocket I found in some > response here. I have verified it ships with FPC so I don't have to do > any install or such to get it too. > > But since I did not find any documentation "for Dummies" on > TInetSocket I am not at all sure what I should do to add a therad to > manage it via an event handler.
The MSEgui socket components (and the pipe reader and RS232 components too BTW) implement the model Michael describes. They have the event properties "oninputavailable" and "onsocketbroken". If you like to build something like this yourself based on "TInetSocket" the code is here: https://gitlab.com/mseide-msegui/mseide-msegui/tree/master/lib/common/ifi (msesockets.pas) https://gitlab.com/mseide-msegui/mseide-msegui/tree/master/lib/common/serialcomm (msesercomm.pas) https://gitlab.com/mseide-msegui/mseide-msegui/tree/master/lib/common/kernel (msepipestream.pas). Martin -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
