Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>HTTP works over TCP, and to understand the working of TCP sockets better you have to think of them as a stream rather than packets.</p> <p>For further clarity, read my earlier post: <a href="https://stackoverflow.com/questions/6076254/recombine-split-tcp-packet-with-flash-sockets/6076716#6076716">recombine split TCP packet with flash sockets</a></p> <p>As to why you receive only 1400 (or so) bytes, you have to understand MTU and Fragmentation. To sum it up, MTU (Maximum Transmission Unit) is the ability of the network to transfer a single packet of a certain maximum size. MTU of a entire network is the lowest MTU of all the routers involved. Fragmentation is splitting up of the packets if you try to send a single packet of size larger than the MTU of that network.</p> <p>For a better understanding of MTU and Fragmentation, read: <a href="http://www.miislita.com/internet-engineering/ip-packet-fragmentation-tutorial.pdf" rel="nofollow noreferrer">http://www.miislita.com/internet-engineering/ip-packet-fragmentation-tutorial.pdf</a></p> <p>Now as for how to receive the entire page in the buffer, one alternative is to keep calling <code>recv()</code> and appending the data you get in a buffer, until <code>recv()</code> returns <code>zero</code>. This will work because typically a web-server will close the TCP connection after it sends you the response. However, this technique will fail to work if the web-server doesn't close the session (maybe keep-alives are configures).</p> <p>Therefore, the correct solution would be to keep receiving until you have received the HTTP header. Take a peek and determine the length of the entire HTTP response (<code>Content-Length:</code>) and then you can keep on receiving until you have received the exact amount of bytes you were supposed to receive.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload