Sending data:
Assume you already have a socket established.
Then sending on the socket is just as in the example:
clientConnection->write(block);
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
out << QString("test");
clientConnection->write(block);
To copy to clipboard, switch view to plain text mode
You need a byte array. You define a Datastream based on the byte array.
You feed the byte array with data and when finished you just write it to the socket.
Thats how you send data.
Receiving data is that you react on the signal bytesAvailable() of the socket.
You get again a datastream. It is now similar to sending data.
But for this one it is important to understand that the signal just tells that some data has arrived, not that all data has arrived.
It is your job to check if everything is already there what you need. That's why in the Fortune example the first thing transmitted is the length of your packet (which I have removed in above example).
Any futher hint needed?
Bookmarks