Archived

This topic is now archived and is closed to further replies.

BlitzKrieg

Network byte order

Recommended Posts

BlitzKrieg    122
If i am transferring data between little endian and big endian computers, i need to call htons() etc. on my shorts and longs. I am assuming i would still need to do this even if i am converting everything to an array of bytes before sending it? If so, how do i get a correct byte order for float''s, double''s etc. that aren''t longs or shorts? Or do i just have to make sure that if i am going to use data other than only bytes shorts and longs, i will only run the program on little endian systems? Thanks

Share this post


Link to post
Share on other sites
Prefect    373
You shouldn''t be sending floats across the network in the first place. The bit layout of floats can vary a lot between different machines, so basically you can either scale your values and send them as integers (of course, that only works if your floats aren''t really _floating_ point), or you will have to deal with the per-CPU-type internal layout of floats. Good luck.

cu,
Prefect

Return to the Shadows

Share this post


Link to post
Share on other sites
BlitzKrieg    122
Thats ok, i have a friend who knows ASM! haha
Thanks for that, hopefully the majority of the programs will be run on x86 machines, if it''s neccessary to run it on something else we''ll cross that bridge when we come to it.
Thanks,
CYer, Blitz

Share this post


Link to post
Share on other sites