If I want to transport a signed long (32 bit integer) across the network what do I do? If I send as a signed long then at other end I won't know (potentially) how remote machine represents signed numbers? So what do I do?
Just use ntohl and htonl and cast or implicitly convert back and forth between uint32_t and int32_t.
Because ntohl() operates on byte-order, so it doesn't care much about the sign, all it cares for is how many bits are there. To answer the question in title.
To answer the question "what do I do?" beyond stating that you're asking question — you convert it to unsigned and then convert back on the other sign, because besides not knowing whether it's signed or not, the arbitrary remote also doesn't know what this number is about and your particular remote may be more knowledgeable of the matter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With