void MyServer::sendToClient(QTcpSocket* pSocket, const QString& str){ QByteArray arrBlock; QTextStream Qcout(stdout); //Qcout<<str.size(); //QTextStream out(&arrBlock,QIODevice::WriteOnly); QDataStream out(&arrBlock, QIODevice::WriteOnly); out.setVersion(QDataStream::Qt_4_4); out << (quint16)0 << str; out.device()->seek(0); out << quint16(arrBlock.size() - sizeof(quint16)); //Qcout<<quint16(arrBlock.size() - sizeof(quint16)); pSocket->write(arrBlock);}