[Standards] Network IO best practices
teddsterr at outlook.com
Sun Jun 10 13:15:39 UTC 2018
It sounds like you're trying to take the incoming XML stream as-is and separate it into stanzas without properly parsing the XML. You will need to parse the XML anyway to make use of it, so you may as well do it as it comes in.
Buffer the incoming raw data, and then parse XML components, and complete stanzas out of that - then you can create Stanza objects and put them into a queue ready for handling. A complete stanza is any opening presence/message/iq up to and including its closing tag. On rare occasions you will find you only have half a stanza in your buffer, so you'll need to be able to continue its parsing once more data is received.
Most implementations use an XML parsing library, so they build a tree/structure from its output.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Standards