[Qt-interest] Broken buffer in QSslSocket?

Bastian Bense bastibense at gmail.com
Mon Mar 30 19:40:03 CEST 2009


Hey again, guys.

I came a across a weird problem yesterday regarding QSslSocket:

One of the projects I'm working on allows a user to send and receive
files. The whole connection is done via SSL, so I have to use
QSslSocket to tunnel everything through there.

After making the transfer itself work properly, I figured that it now
would be time to implement some basic speed limiting. I figured that
(for receiving data) using setReadBufferSize(250000) - for 250 kb -
and having a QTimer call a slot that reads all data that are in the
buffer every second. - I'm sure there is a better and more efficient
way, but this works for now.

As soon the data transfer starts, the socket's read buffer is filled
with the data arriving from the other side and after a second the slot
to read my data is called. The slot reads the data from the socket and
since the buffer is now cleared, the socket should continue receiving
more data until the buffer is full again.

This is where the problem comes in. After the first attempt to read
the data from the socket, the socket does not keep receiving and gets
stuck. A quick check reveals that bytesAvailable() returns 0 [sounds
good], but encryptedBytesAvailable() returns 1024 [doesn't sound so
good]. I figure that as long there is some data remaining in the
socket's incoming buffer, the socket won't receive any further data
over the network.

I made a little test case to explain my point and reported a bug to
Nokia already, but it would be nice to know if there is a workaround
for this (possibly there is a minimum size for setReadBufferSize() or
something similar)?

http://nex.neo.de/s/sslsocket_testcase.tar.gz

Thanks in advance!
Bastian

-- 
Best regards,
Bastian Bense



More information about the Qt-interest-old mailing list