title: How to efficiently define End-of-Transmission for XML-based text protocol?
body: <p>I want to develop a text protocol based on XML and transmitted via TCP/IP sockets.
  Let's say I have a simple request/response mechanism to be send over a persistent
  TCP/IP connection between client and server like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;request id="1" command="get.answer"&gt;
      &lt;value type="string"&gt;Answer to the Ultimate Question of Life, the Universe, and Everything&lt;/value&gt;
  &lt;/request&gt;
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;response id="1" command="get.answer"&gt;
      &lt;value type="int32"&gt;42&lt;/value&gt;
  &lt;/response&gt;
  </code></pre>
  
  <p>When should each side start to process the incoming data or in other words
  when would the server know that the incoming client data is fully transfered
  and possible to process to create a response?</p>
  
  <p>Of course I made some research about that topic:
  I found <a href="https://stackoverflow.com/questions/6593969/simple-chat-protocol/6594192#6594192">this</a> answer which points in the right direction based on an HTTP example:
  So using a kind of 'Transfer Protocol' on top of the XML messages would certainly help.</p>
  
  <p>But I also looked at the purely XML-based XMPP protocol which doesn't use any
  'Transfer Protocol' like HTTP at least as far as I have seen.</p>
  
  <p>From RFC 6120 at "2.4. Structured Data" it reads:</p>
  
  <blockquote>
    <p>The basic protocol data unit in XMPP is not an XML stream (which
    simply provides the transport for point-to-point communication) but
    an XML "stanza", which is essentially a fragment of XML that is sent
    over a stream.  The root element of a stanza includes routing
    attributes (such as "from" and "to" addresses), and the child
    elements of the stanza contain a payload for delivery to the intended
    recipient.</p>
  </blockquote>
  
  <p>So they send basically small XML chunks over TCP/IP w/o 'Transfer Protocol' and from
  my wireshark traces I can see that there is also no special End-Of-Transmission character
  at the end of each XML stanza like two times \r\n or something like that.
  So how do they know about the end of a message (stanza)?</p>