HTTP works over TCP and better understands the operation of TCP sockets, so you need to think of them as a stream, not packets.
For clarity, read my previous post: recompile TCP packet with flash sockets
As for why you only get 1400 (or so) bytes, you have to understand MTU and fragmentation. To summarize, MTU (Maximum Transmission Unit) is the ability of a network to transmit one packet of a certain maximum size. The network-wide MTU is the lowest MTU of all routers involved. Fragmentation is packet splitting if you are trying to send one packet larger than the MTU of this network.
For a better understanding of MTU and fragmentation, read: http://www.miislita.com/internet-engineering/ip-packet-fragmentation-tutorial.pdf
Now, how to get the whole page in the buffer, one of the alternatives is to continue calling recv() and add the data you get in the buffer until recv() returns zero . This will work, because normally the web server closes the TCP connection after sending the response. However, this method will not work if the web server does not close the session (perhaps keep-alives are supported).
So the correct solution would be to keep getting until you get the HTTP header. Take a look and determine the length of the entire HTTP response ( Content-Length: , and then you can continue to receive until you get the exact number of bytes that you should have received.
source share