I have this to write some data to a socket.

Qt Code:
  1. QDataStream out(&data, QIODevice::WriteOnly);
  2. out.setVersion(QDataStream::Qt_4_1);
  3. out << int(0x02) << QString("text");
  4. tcpSocket->write(data);
To copy to clipboard, switch view to plain text mode 
The Socket connects perfectly, and the data is sent however the results seen at the receiving end are not what i expected... I know there is a simple fundamental problem with the way I am defining the data to send.. i just cant see it..

I want to see this on the other end. It can only be this since this is a tool to integrate to an existing protocol.


0x02 74 65 78 74 0A

Which is [0x02]text[0x0A]


But I keep getting this..

0x00 00 00 02 00 00 00 08 00 74 00 65 00 78 00 74

[0x00 00 00 02 00 00 00 08 00]t[0x00]e[0x00]x[0x00]t