2 ms·
Obviously if you are interacting with an old protocol that uses network byte order for some things, you will need to use these functions. But what's the argume
by Negitivefrags 5y ago
Obviously if you are interacting with an old protocol that uses network byte order for some things, you will need to use these functions.
But what's the argument for using them in new game code?
The code will not be running anywhere that has big-endianness. No current platform a game could run on uses it, and I can't imagine a scenario where a new platform would come into existance and use it either.
If you insist on using network-byte order anyway, then you have to do an extra bswap op for each bit of data you send. Sure, the cost of that is super minor and probably not worth worrying about.
But the bigger cost is that you can't just send whole structures at a time. You have to individually serialise each thing. Now you have to have a whole serialisation concept. You have to have some way of enumerating all the fields. You have to walk all the structures. What a pain.
If you want to send a thing over the network, just send it.