Due to a bunch of stupid issues in C with autocasting, sensible ways of parsing network bytes into something like an int might not work as expected, for which see here:
https://justine.lol/endian.html
The solution is something like this (mutatis mutandis if the incoming thing is little endian).
https://news.ycombinator.com/item?id=27086482
uint32_t read32be(const uint8_t *p) {
return (uint32_t)p[0] << 24
| (uint32_t)p[1] << 16
| (uint32_t)p[2] << 8
| (uint32_t)p[3];
}