Quote Originally Posted by Kill3rReaper View Post
(4000 chars = 4000 bytes).
Not always true! Check encodings!

He sending it in one message, but I receive 3 packets (size of one packet depends for MTU; for example MTU = 1500 - most popular). I have got:
1: 1500 bytes
2: 1500 bytes
3: 1000 bytes
The size of each one is very often changeable, and in very places (routers for example) MTU can be different. I never know how large is packet and when message is complete.
I hope, you're understanding what I mean.
I do, and no, you're not going to find TCP network infrastructure that sends you a gigabyte in one single packet. That would be silly.
So, what to do...

You need to receive a single file or message but it comes in several packets.
A good protocol tells you when the data ends. In HTML for example, the size of the body is mentioned in the headers. In NNTP, a multiline message ends with \r\n.\r\n.
So, find in the protocol you want to use how the server tells the clients that a specific request has ended.