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:
<?xml version="1.0" encoding="UTF-8"?>
<request id="1" command="get.answer">
<value type="string">Answer to the Ultimate Question of Life, the Universe, and Everything</value>
</request>
<?xml version="1.0" encoding="UTF-8"?>
<response id="1" command="get.answer">
<value type="int32">42</value>
</response>
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?
Of course I made some research about that topic: I found this 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.
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.
From RFC 6120 at "2.4. Structured Data" it reads:
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.
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)?