Closed wsyOverflow closed 3 years ago
Out of box TCPSession provides streaming protocol. What you want is called messaging protocol. You should apply messaging protocol in your user code. Very simple example is to send data length in first 4 bytes (int length) and then receive, collect in array and wait for a whole data. When you receive the message then process it in your code.
You for message based protocol you might look into my FastBinaryEncoding project. Idea that I described above is implemented here - https://github.com/chronoxor/FastBinaryEncoding/blob/master/proto/fbe_protocol.cpp
Thanks for your explanation, I will implement that you suggested
I create a TCPSeesion followed by the TCP Chat example. However, I found my TCPSession can not received the whole buffer in one call of onReceived function when my client sent a large amount of data. The remaining data sent by client will be received by the next call of onReceived function. It seems receiving data by chuncks even the client sends the data in one sending.
How can I know my server has received all the data sent by client at a sending?