XMPP interleaved binary ---- S: S: S: C: S: Starting after the final '>' character, all data exchanged with the server must use this framing format: [1-bit type] [15-bits length] [value bytes] The length is a 15-bit unsigned integer, and the bits are ordered starting with the most significant bit. The length indicates the number of value bytes that follow. If the number of value bytes to send is larger than can be represented in 15 bits, then the data should be sent using more than one frame. For example: 00 0B 3C 70 72 65 73 65 6E 63 65 2F 3E Would mean: Type: 0 Value: Type 0 is XML, type 1 is binary. The binary type can be used in place of base64 encoded data. The following two transmissions are equivalent (whitespace added for clarity) C0: C0: C0: SGVsbG8gd29ybGQ= C0: C0: C0: C0: C1: Hello world C0: C0: The framing protocol sits under the XML stream, however it is always above all other layer negotiations. For example, if TLS or compression is negotiated, then the entire interleaved stream is encrypted or compressed, not simply the type 0 XML data. These layer negotiation protocols have an indicator for where the new layer should begin (for example, with TLS, this is after the final '>' of ''). When using interleaved, the new layer begins after the type 0 frame containing this indicator. Since the interleaved framing protocol has no footer, this point is mostly moot (the last byte in the frame containing '' would be '>', so it works out the same whether or not interleaved framing is used).