qtqt4qtcpsocketqbytearrayqsslsocket

Send QDataStream through QTcpSocket or QSslSocket


I want to send serialized data through ssl or tcp socket. QIODevice::write doesn't send QDataStream but only char* and QByteArray.

Is there a way I can send serialized data through socket? Or how can I convert QDataStream to QByteArray?

Thanks


Solution

  • Pass your QIODevice to the QDataStream constructor. This will allow you to write to the device through the stream.