[Lazarus] TInetSocket usage - any documentation available?

Bo Berglund bo.berglund at gmail.com
Wed Oct 21 00:33:11 CEST 2015


On Wed, 23 Sep 2015 10:21:58 +0200 (CEST), Michael Van Canneyt
<michael at freepascal.org> wrote:

>On Wed, 23 Sep 2015, Bo Berglund wrote:
>
>> I have looked for a native FPC TCP/IP socket to use as a replacement
>> for a serial port component and I discovered the ssockets unit that
>> ships with FPC and contains a TInetSocket class.
>> This seemed useful.
>
>> The data shifted through the socket will be EXACTLY the same as was
>> earlier transferred by RS232.
>>
>> Any suggestions on where I can find suitable documentation?
>>
>
>Shortly said: There is none.
>
>If the various demo programs are not understandable for you, you are out of luck :(
>
>Now, from what you describe, all you need to do is use the read/write
>methods to send and receive data, just as in any stream: the client 
>TInetSock is a TStream descendent.
>
>Thread programming is not so difficult, but I am not convinced that for the 
>use case you describe, threads are really needed (despite suggestions to the 
>contrary on this list).

Thanks for the pointers!
Back in September I was looking for the solution on this but at the
time not yet on an RPi2, but on Windows. I was also then adviced to
search for an example of TInetSocket and had a look at ssockets usage
in the example:
lazarus\fpc\2.6.4\source\packages\fcl-base\examples\dsockcli.pp

But the example is pretty limited regarding how one actually
communicates using the sockets provided by ssockets.
All it seems to do is to connect to a server and write the same line
of text 10 times over and then quit.

What I must do is plug a socket into the existing code where there is
bidirectional data transfers using a receive event and there will be a
response for each packet sent.
In another thread on the fpc list I was directed towards an example I
could download from:
https://github.com/silvioprog/tcpipcomp

And it looks more complete, there is a chat example which implements a
bidirectional system using a thread too.
I will try to stuff this into the existing code if possible...

As Mark Morgan Lloyd has pointed out I *really* need to create an
encapsulated class for the TCPIP communications so I can use this as
an alternate component in the existing object and for this I need to
implement an onReceive event to plug the incoming data into it.
Otherwise I am in for a really big rewrite of the class.

Struggling on...


-- 
Bo Berglund
Developer in Sweden





More information about the Lazarus mailing list