Question: I'm writing a program that uses QUdpSocket for transmitting data over the network. This is my first socket program, and I've come across an interesting problem called Endianness.

My actual question in, do I have to worry about Endianness when I'm using QNetwork as my sockets library? If I do have to worry, what do I have to do to properly avoid Endianness problems?

Answer: 
Generally, you need to worry about endianness (byte-order) when you transfer integers larger than a single byte from one computer to another. In C/C++, this means that if you're sending something like a 16-bit, 32-bit or 64-bit integer, you need to first convert the integer to *network byte order*, (also known as Big-Endian). The computer on the receiving end must then convert the incoming integers to *host byte order*, which is whatever byte-order the host-machine uses natively. This is usually done using the `htons` and `ntohs` series of library functions, but with the Qt library you can also use the `qToBigEndian` and `qFromBigEndian` functions.

Note that you don't need to worry about endianness when sending ASCII or UTF-8 text, because these formats are composed of sequences of individual bytes, rather than multi-byte data types.
Here's a simple test for big endianness, in case you want it:

// This test assumes an int size of at least 2.

static const int testValue = 1;

#define is\_bigendian() ( (*(char*)&testValue) == 0 )

bool CD\_is\_bigendian(void)
{
 return is\_bigendian();
}