I know that there are things out there roughly on this.. But my brains hurting and I can’t find anything to make this work…
I am trying to send an 16 bit unsigned integer over a unix socket.. To do so I need to convert a uint16_t into two chars, then I need to read them in on the other end of the connection and convert it back into either an unsigned int or an uint16_t, at that point it doesn’t matter if it uses 2bytes or 4bytes (I’m running 64bit, that’s why I can’t use unsigned int 🙂
I’m doing this in C btw
Thanks
Why not just break it up into bytes with mask and shift?
(edit)
On the other end, you assemble with the reverse:
Off the top of my head, not sure if that cast is required.