Basically the problem is very simple to solve. Normally you don't just use TCP but you add an application layer on top of it. That means you have to define your own rules for messages. For example, you could send an integer from the client to the server (always 4 bytes long) that defines the length of the string to read from the stream. Then you read the amount of bytes defined by the first integer and go over to the next message which follows the same format. Alternatively, you could use null terminated strings or whatever you like.


Your friendly mod is at your service.