void MyServer::sendToClient(/*QTcpSocket*/ QIODevice *pSocket, Message *toSend){ QByteArray arrBlock; QDataStream out(&arrBlock, QIODevice::WriteOnly); out.setVersion (QDataStream::Qt_4_8); out << quint16 (0) << QTime::currentTime() << *toSend; out.device ()->seek (0); out << quint16 (arrBlock.size()- sizeof(quint16)); pSocket->write (arrBlock); pSocket->waitForBytesWritten (50);}void MyClient::slotReadyRead (){ QDataStream in (m_pTcpSocket); in.setVersion (QDataStream::Qt_5_3); for (;;) { if (!m_nNextBlockSize) { if (m_pTcpSocket->bytesAvailable() < sizeof(quint16)) break; in >> m_nNextBlockSize; } if (/*dataAvailable*/m_pTcpSocket->bytesAvailable() < m_nNextBlockSize) break; QTime mytime; QString str = mytime.toString(); in >> mytime >> *lastMessage;.....}