5.2.1 Length
Via Tomoaki Yamaguchi.
The Length field is either 1- or 3-octet long and specifies the total number of octets contained in the message (including the Length field itself).
If the first octet of the Length field is coded “0x01” then the Length field is 3-octet long; in this case, the two following octets specify the total number of octets of the message (most-significant octet first). Otherwise, the Length field is only 1-octet long and specifies itself the total number of octets contained in the message.
The 3-octet format allows the encoding of message lengths up to 65535 octets. Messages with lengths smaller than 256 octets may use the shorter 1-octet format. 5.2.1 Length
The Length field is either 1- or 3-octet long and specifies the total number of octets contained in the message (including the Length field itself).
If the first octet of the Length field is coded “0x01” then the Length field is 3-octet long; in this case, the two following octets specify the total number of octets of the message (most-significant octet first). Otherwise, the Length field is only 1-octet long and specifies itself the total number of octets contained in the message.
The 3-octet format allows the encoding of message lengths up to 65535 octets. Messages with lengths smaller than 256 octets may use the shorter 1-octet format. 256 should be changed to 255. 255 + 1 = 256 but the hex value of 256 is 2 octet. 254 + 1 = 255 = 0xff. 255 + 3 = 258 = 0x0102
- Related to
-
MQTT-547 Consider whether current length encoding is acceptable
- Closed