Why the TClientSocket.OnRead event is fired twice to send a single server

So, I have a TClientSocket, which should receive more than 10 Kbytes of data in a single OnRead event. But when the event is triggered, it receives only 8 Kbytes of data, then the event fires again with the rest of the data.

Why is this happening?

+3
source share
2 answers

Because TCP is a flow protocol, not message based. You should receive everything that was sent, combine it into one data stream, and then analyze the stream in accordance with the protocol used.

+12
source

, , .

+2

Source: https://habr.com/ru/post/1774050/


All Articles