Maybe I am working too much with serial ports these days but ... protocols WITHOUT any clear markers to resync the byte stream against seem ... idiotic to me. Like why define a "protocol" that has a "fixed header" that consists of a length and a command, followed by a payload of said length? If you're using a transport that preserves message boundaries, there's no need for the length in the first place. And if you're using a transport that doesn't preserve message boundaries, well, now you cannot EVER get back in sync if anything goes wrong. Sooooooo ... maybe I am stuck in the 1980s or something but ... put a frickin' magic number and a checksum gosh-darn-it. If you don't, it's not a "protocol" in my eyes. #rant #protocol #MagicNumber
"But the transport is reliable! You cannot possibly lose bytes so you're always in sync!" That's great. Let's hope you're never asked to move it to any other kind of transport.