I sent a 258-byte dummy line in a toy meter display. On the wire its length says 02 01. My x86 app read that as 258 so I shipped the demo to the router and it waited for a whole 513. Our other fixture is just the word hello; that one's got ambitions too.
Write 258 as hex: 0x0102. In network order the first byte is 01. A little-endian host writing the raw integer gives you 02 01. Your two laptop programs told each other the same lie.
Right. htons at the boundary on send, ntohs on receive, no dumping my whole struct on the wire. Also found two padding bytes between the flag and my count on one build. They were just sort of. there.