You have to thing about that TCP is like a pipe where data can be transported in. On top of that, you can implement what ever protocol or message system you like.
Say you what to send and receive a file. Then you have to tell the receiver some information about that file you will sent. It can be file name, create date/time and the size of the file.
When the receiver knows about that info, it will know how to interpret the data received.
See how
HTTP protocol[
^] is built up. Its been used for many years now.