Hello,
I'm reading from a tcp server an integer (4-bytes) data
The tcp server is big endian
On my client, which is a little endian CPU, I've done this :
qint32 v;
...
sck.read(data, 16);
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
v = ntohl(*((qint32*) data));
#endif
QTcpSocket sck;
qint32 v;
...
sck.read(data, 16);
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
v = ntohl(*((qint32*) data));
#endif
To copy to clipboard, switch view to plain text mode
Works pretty well, but sounds "old school". Do I have a better way to do that ?
Thanks...
Bookmarks