TCPSocket

Hi all. I’m using TCPSocket to send instructions to a server for it to then return results back to the client. When the server does it’s write, and the client accepts the data with DataAvailable, how does the client know when the server has finished sending its chunks of data? Is it just a case that the server TCPSocket disconnects itself, thus firing an error event on the client side? Thanks in advance.

That’s up to you. There is another, recent thread about this on the forum, so you can look for advice there, but the short answer is, include something in the packet that will tell you when the data is done. That can be a header that contains the packet length, or some character that wouldn’t naturally occur in your data that indicates EOF.

1 Like

Thanks Kem, never occurred to me to do it that way. Simples!

1 Like