[Lazarus] TInetSocket usage - any documentation available?

Bo Berglund bo.berglund at gmail.com
Wed Sep 23 06:05:22 CEST 2015


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.
So I put together a test console application in Lazarus 1.4.0 where I
had this in order to verify that FPC would find it:
[code]
procedure TSSRemoteTestApp.DoRun;
var
  ErrorMsg: String;
  FSSConn: TInetSocket;
begin
  //Stuff added by Lazarus removed .....
  { add your program here }
  FSSConn := TInetSocket.Create('10.0.0.2', 2001);
  // stop program loop
  Terminate;
end;
[/code]
After I added the ssockets unit to the uses clause this compiled and
so it seems like it will work.

My next problem is actually finding some description on what one can
do with that object...
Is there somewhere a comprehensive guide on usage of this socket in a
simple case as mine:
- Connect once and keep connection until end of program
- Send commands and binary data via a TCP/IP socket to the other end
- Fire an event when there are data received so they can be handled

I think that TInetSocket is actually blocking so I would have to use
some thread or such to retrieve incoming data and decode that and feed
it to the main program level for processing.
But how? I have only minimal info on what the TInetSocket can actually
do.
When I google TInetSocket I get results that are not referring to this
socket at all. Instead they refer to general TCP/IP articles or
descriptions of OTHER socket implementations. :(

My reason for this:
I have a quite large Delphi project for communications via RS232 to a
data collection system. This was developed over several years.
Now I need to create a new application that must run on an ARM
embedded platform (first test will be Raspberry Pi2) and communicate
via WiFi to the data collection system. It must use my existing
Delphi7 classes to control the instrument and manage the data, but
replace the RS232 component with a TCP/IP socket component available
on FPC.
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?

-- 
Bo Berglund
Developer in Sweden





More information about the Lazarus mailing list