Socket communication

Does anybody have any references on where I can find documentation for, or have some advice for, how to properly handle communication between a local and remote system? Here’s an issue I’m having. Thankfully, Xojo handles the TCP socket stuff (and from what I’ve tested, pretty damned effectively and efficiently… kudos to the guy(s) on the backend who has been working on these). Where I’m running into an issue, is I have several threads on a device that monitor different things… and call a command back to the remote server, and expect a specific response (whether the operation was successful, failed, etc.) Seems simple enough, but if the local device sent a command from one thread… and the server is processing the return, but another thread sends a command in the middle of that transmission… it gets extremely difficult to manage responses. I’ve tried variations of a ‘busy’ flag, sending each command instance with a UID, incorporating some kind of queue system, etc. and no solution I found was solid. Most work effectively about 90% of the time, but I’m finding it difficult to handle the smooth transmission and keeping it reliable and solid. You’d think this would be fairly simple, and perhaps it is and I’m making it harder than it has to be. I dunno… and any advice would be highly appreciated!

Nevermind, I got a solution working (which most probably did to begin with). My instability was sometimes it would send a command before the sslConnected was completed. This broke my methods. I now connect, and wait before this is flagged to start processing commands. I just now stumbled upon this by luck…

you may also want to make sure that whatever the protocol is it has a means to tag requests & responses so if you send & receive you can match requests & responses to each other
Dunno if you control that but say you do the following)

request 1 -> server
request 2 -> server
client <- response 2
request 3 -> server
client <- response 1
client <- response 3

if you can’t match replies to requests your going to have issues
99% of the time you might get

request 1 -> server
client <- response 1
request 2 -> server
client <- response 2
request 3 -> server
client <- response 3

but the few times you get something in any other order you’re in trouble

Norman, I do… I attached a unique ID with each command, and the remote reply has it attached as well for this purpose. Appreciate the feedback!