Here is a small block of code above a read() statement in a synchronous TCP client that I've written.
std::cout << "available? " << socket->bytesAvailable() << std::endl;
socket->waitForReadyRead();
std::cout << "reading..." << std::endl;
bytesRead = socket->read(message + totalBytesRead, messageSize - totalBytesRead);
The following line:
socket->bytesAvailable()
returns 4, so there is obviously data available to be read. The problem that I'm having is that waitForReadyRead() is blocking until the default timeout of 30 seconds. Read() then proceeds to read 0 bytes on the following line.
So if there are bytes available to be read, why does waitForReadyRead() block