I would like to do some client and server to sharing files each other. I have an issue, because TCP “messages” are merged, despite I set how many bytes I would like to send and how many receive.
I had a look on it, and the problem occurs when in the first “message” I send a filename and after that (in new Send()) I send the file content, for example.
I fixed it by sending a feedback message after each receive packet currently.
Is there any better way to do that?
Add a length prefix to each message. And then read in a loop until you receive as many bytes as you want.