Skip to content

Instantly share code, notes, and snippets.

@oppahero
Created November 8, 2018 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oppahero/8864d81fa71cbf0e4847d4b6292c925e to your computer and use it in GitHub Desktop.
Save oppahero/8864d81fa71cbf0e4847d4b6292c925e to your computer and use it in GitHub Desktop.
void Dialog::sendTextToServer(QString text){
QByteArray block;
QDataStream out(&block,QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_5_3);
qDebug() << "texto: " + text;
out << (quint32)0 << text;
out.device()->seek(0);
out << (quint32)(block.size() - sizeof(quint32));
qint64 x = 0;
while(x < block.size()){
qint64 y = tcpSocket->write(block);
x+=y;
qDebug() << x;
}
qDebug() << "-----";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment