ok, i use it this way:

server send-method
Qt Code:
  1. void Server::send_xml_data(QString message) {
  2. blockSize = 0;
  3. QString out_string = message;
  4. QByteArray block;
  5. QDataStream out_stream(&block, QIODevice::WriteOnly);
  6. out_stream.setVersion(QDataStream::Qt_4_7);
  7. out_stream << (qint16)0;
  8. out_stream << out_string;
  9. out_stream.device()->seek(0);
  10. out_stream << quint16(block.size() - sizeof(quint16));
  11. socket->write(block);
  12. }
To copy to clipboard, switch view to plain text mode 
client-readyReadSlot-method:
Qt Code:
  1. void Client::readyReadSlot()
  2. {
  3. qDebug() << "readyReadSlot()";
  4. QDataStream in(socket);
  5. in.setVersion(QDataStream::Qt_4_7);
  6. if (blockSize == 0) {
  7. if (socket->bytesAvailable() < (int)sizeof(quint16))
  8. return;
  9. in >> blockSize;
  10. }
  11. if (socket->bytesAvailable() < blockSize)
  12. return;
  13.  
  14. QString result;
  15. in >> result;
  16. receive(result); //process my data
  17. }
To copy to clipboard, switch view to plain text mode