[Qt-interest] Send a pdf thru QTcpSocket. Encoding problem?
Thiago Macieira
thiago.macieira at trolltech.com
Wed Feb 4 09:20:58 CET 2009
Josinei Silva wrote:
>I'm trying to send a pdf created by my own Qt application printing to a
> file thru a QTcpSocket ( It's working with threads now. Thanks Thiago
> ). But the pdf that i received is not the same i sent.
Why are you using base 64 and QDataStream? Why not just send the byte
array size and the byte array itself? The base64 encoding is completely
unnecessary, since your channel is 8-bit clean.
Just be careful with endianness when sending the size.
Also note the following potential errors:
- waitForBytesWritten waits for any bytes written, not ALL bytes written
- there's no code in the receiving side to wait for all necessary bytes
to arrive
- you write a QByteArray into the QDataStream, but you read a QString
--
Thiago Macieira - thiago.macieira (AT) nokia.com
Senior Product Manager - Nokia, Qt Software
Sandakerveien 116, NO-0402 Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090204/40d6879e/attachment.bin
More information about the Qt-interest-old
mailing list