If you're interested in Bitcoin rather than TCP, then you shouldn't really worry about this: just stick all of the TCP payloads together.
Try writing a simple TCP server and client in C or something using the basic syscalls. It's pretty simple, and it'll give you more understanding of how it works from the perspective of a TCP user.
I'm actually interested in both and kind of learning everything at the same time!
Your comment helped a lot as a matter of fact. I've changed my
MessageManager class which is supposed to handle these received byte arrays and now it looks for the
Magic in messages and based on first 24 byte of header and the
PayloadSize inside of it, I decide how much of the packet is remaining or how to generally go on from there.
Now everything works fine and life is beautiful again after 1 week of struggling.
Thanks.