[Qt-interest] QTcpSocket problems

Donal O'Connor donaloconnor at gmail.com
Mon Aug 3 18:19:19 CEST 2009


Hi There,

I've a Java server sending a string of data (16114bytes).

I use QTcpSocket to connect to this server, send a request for data (which
works fine) but when I wait to read, i only get the first packet of data.
Packets are sized at 1460 bytes.

This is my reading code after I write the request:

if (m_tcpSocket->waitForReadyRead(5000))

{

QByteArray inputData;

while(true)

{

qDebug() << "Remaining bytes: " << m_tcpSocket->bytesAvailable();

QByteArray thisBuffer;

thisBuffer = m_tcpSocket->read(m_tcpSocket->bytesAvailable());

if (thisBuffer.size() == 0)

break;

else

inputData += thisBuffer;

}

QString returnedString = QString(inputData).trimmed();

returnLines = returnedString.split("|");

}

else

qWarning() << "Error reading response";

I only get 1460 bytes (the packet size on this network). I've used
Wireshark, and I can see that the Java server is sending out all the packet
data but I only get one packet.
0 Bytes are available after the first read occurence.

I even tried putting in a sleep before the while loop of a second...and
within the while loop during the loop and no joy. Always 0 bytes available
after the first 1460.


I'm using Windows CE. I'm getting strange behaviour in general from sockets
on this device..

Is the code I'm using correct or am I doing something stupid?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090803/0bce2841/attachment.html 


More information about the Qt-interest-old mailing list