I'm porting a TCP/IP client from wxWdigets to Qt. I've tried this under both 5.4.2 and 5.6.2.

I have a user-configured timeout value for network reads. The default is 300 seconds (5 minutes). I am feeding that to QTcpSocket::waitForReadyRead(), and it's basically ignoring--worse, it's generating an error. It doesn't seem to matter if it's 300,000 msecs or 3,000,000 msecs, I get "Network operation timed out" (5) returned from it.

        int msecs = timeout * 1000000;
        if(!socket.waitForReadyRead(msecs))
        {
QString msg = QString(tr("An error occurred while receiving data from the server: \"%1\" (%2).")).arg(socket.errorString()).arg(socket.error());
            ...

This causes the communications to fail, even though the action takes place pretty much instantly, because I'm running the server on the same machine for testing/debugging. If I tell QTcpSocket::waitForReadyRead() to wait forever:

        if(!socket.waitForReadyRead(-1))

everything runs smoothly.

I've done nothing with the QTcpSocket instance in terms of configuration. I just create it, and then start the ball rolling with a call to connectToHost(). Have I not configured some Qt5-thing correctly?
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to