Hello.
I am not sure where ask this question, so I try here.
I am working on a little daemon (server), written in FreePascal on|for Linux. It will communicate with IoT clients through TCP/IP.
My problem is this extremely unreliable
NB-IoT. Sometimes Round-Trip-Times of 3-5 seconds, sometimes connection loss, ...
I wrote a function to transmit a data packet. It sends a string, then it awaits the confirmation (a string with 'ACK'+<CRLF>). I configured a very long timeout of 15s for receiving a response (because of this sometimes long delays).
// Send data
function SendDataBlock(DataBlock: string): boolean;
var s: string;
begin
ASocket.SendString(DataBlock+CRLF); // Send Data
s:=ASocket.RecvString(timeout_rcv); // Await respoonse
SendDataBlock:=pos('Ok',s)>0;
end;
This function works fine, as long something is received. But it rises an Exception when Synapse reaches the timeout (line 6).
Is there a simple way to make RecvString return an empty string on timeout, or to detect and trigger on timeout?
I spent lots of time on finding any useful documentation, code examples, etc., but I had no success. Is there any "code collection" available as downloadable PDF, showing how to use Synapse? Need to say, I do not use Lazarus. I use only FreePascal. If somebody wants to see the complete code for better understanding, this is possible on request.