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: 
If you are transferring binary data between two machines with a different endianess you may have to worry.

The network socket will just ship the data unchanged. If the other machines assumes that the bytes it was sent are in a particular order you have to manage that.

If you are transferring data in a known format, like an image then image format generally has something in the header to show what order it was written in and the reader/writer library will handle it.
If you are inventing your own binary format - then it's upto you. You may also have to consider size, how many bytes is an int on the other machine? 

The good news, most machines are Intel and for most applications shipping smaller amounts of data in ascii format will work.
I know this was answered a long time ago, but I just thought I'd add to it.

Instead of using the endian conversion functions, you could use the [QDataStream](http://doc.trolltech.com/latest/qdatastream.html "QDataStream") functionality (with *any* QIODevice), which is *much* easier and more intuitive in my opinion. Of course, that would lock you into using the QDataStream on both the sender and receiver, but it's worth it for that case.

Example usage, for someone else's sample of sending an image:

`QDataStream & operator<< (QDataStream& stream, const QImage& image);`  

`QDataStream & operator>> (QDataStream& stream, QImage& image);`  

(Both of those are already implemented within Qt.)  

`QTcpSocket *tcp = ...;`  

`QImage img = ...;`  

`QDataStream(tcp) << img;`