[Qt-interest] QTcpSocket problems
Donal O'Connor
donaloconnor at gmail.com
Mon Aug 3 19:07:49 CEST 2009
Ok So I've changed a little and it works but this method is not ideal
while (m_tcpSocket->waitForReadyRead(1000))
{
inputData += m_tcpSocket->read(m_tcpSocket->bytesAvailable());
}
I get a TcpSocket time out error from the error signal of the tcp socket
object.
Is there a better way to do this asynchronically rather than using a slot to
wait for ready read signal?
Thanks.
This is not ideal as I don't
On Mon, Aug 3, 2009 at 5:19 PM, Donal O'Connor <donaloconnor at gmail.com>wrote:
> 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/154689f2/attachment.html
More information about the Qt-interest-old
mailing list