Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>Now is there any possibility that server will receive this in more than one read?</p> </blockquote> <p>Yes, TCP/IP can fragment messages any way it likes. TCP is a stateful stream protocol: you are guaranteed that bytes you put in on one end will come out the other end in the same order. IP is connectionless and datagram based. Due to the nature of carrying TCP over IP, circumstances can arise in which data packets are split, merged, or otherwise processed in transit.</p> <p>You should find a way to sanitize your program to the intricacies of network communication. You can:</p> <ul> <li><p>Use a datagram protocol like UDP (you lose the guarantee of getting data in the order they are sent, and dropped packets becomes a possibility as well. Today's networks are fairly robust; this is not usually a problem).</p> <pre><code>[DATAGRAM (size specified in datagram header)] </code></pre></li> <li><p>Always read blocks of a fixed size from the network</p> <pre><code>[DATA - block of data of some fixed size] </code></pre></li> <li><p>Include the size of the incoming data as a header attached to the front</p> <pre><code>[LENGTH - 4 byte integer][DATA - block of data of size LENGTH] </code></pre></li> <li><p>Use some sort of delimiter to indicate end-of-data and continue reading until you get it</p> <pre><code>[DATA - indeterminately sized data][DELIMITER - end-of-data control sequence] </code></pre></li> </ul> <p>Chances are you can use library methods to perform this behavior for you requiring very little code on your part.</p>
 

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