Why TClientSocket.OnRead event fires two times for a single server send
So, I have a TClientSocket which have to receive over 10KB of data in one OnRead event. But when the event is triggered it only gets 8KB of data, then the event fires again with the rest of the data.
Why is this happens?
Because TCP is a stream protocol, not message-based. You must receive whatever you have been sent, merge it to one stream of data, then parse the stream according to used protocol.
You need to write a server-client agreed protocol that will signal the end of the message nad by that to parse the streaming to complete messages.