socketTimeout on subsequent send: how to?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trevix
Posts: 958
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

socketTimeout on subsequent send: how to?

Post by trevix » Sun Feb 05, 2023 10:43 am

My client script, when a write to socket occurs, set a flag var "sWaitingForDataIn" to true (within the callBackMessage).
When receiving an answer from the server, it set the flag to false (the server always responds unless something happened or was busy, or else).
My socketTimeout script is something like this:

Code: Select all

on socketTimeout theID
     if sWaitingForDataIn then
          answer "Not responding. Want to stop? with "stop" OR "Keep on"
          if it is  "stop then 
               close socket theID
          end if
     end if
end socketTimeout
I always thought, for some reason, that any new write or read would replace the pending messages to the socketTimeout code, but apparently it is not true.
I mean, it looks to me that if I do 2 write to socket in a row with the same message, the "on socketTimeout" will receive, after the socketTimeoutInterval, 2 calls. If for a glitch the first one wasn't answered by the server (busy?), while the second try was, the socketTimout will still report the connection problem.
How can I avoid this?

Thanks
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

trevix
Posts: 958
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: socketTimeout on subsequent send: how to?

Post by trevix » Mon Apr 17, 2023 3:19 pm

Hello "socketers".
So, apparently, from my finding, the socketTimeout is called every socketTimeoutInterval from the last write or send.
The timing does not get reset, if there is a new write or read, before the last socketTimeout has been run .
Can someone confirm me this behaviour?

If this is true, any idea on how to solve this and, like in the code above, avoid an answer message, while intercepting an unresolved write or read?
I tried using the seconds and some vars, but to no avail.

Thanks for any help
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”