when to use hton/ntoh and when to convert data myself?
问题 to convert a byte array from another machine which is big-endian, we can use: long long convert(unsigned char data[]) { long long res; res = 0; for( int i=0;i < DATA_SIZE; ++i) res = (res << 8) + data[i]; return res; } if another machine is little-endian, we can use long long convert(unsigned char data[]) { long long res; res = 0; for( int i=DATA_SIZE-1;i >=0 ; --i) res = (res << 8) + data[i]; return res; } why do we need the above functions? shouldn't we use hton at sender and ntoh when