QTcpSocket waiting for write to be read
Hi there. I have a Qt based service which essentially contains this
Code:
s = server.nextPendingConnection();
// ..snip.. (read a command string from s)
s->write(some_string);
s->waitForBytesWritten(-1);
delete s;
A PHP web page connects to it with code like this
Code:
$command = some_stuff;
The Qt service reads the command string fine, but the PHP errors on socket_read saying "connection reset by peer". I guess this means Qt deletes the socket before the read is finished. I could make the PHP write an "I'm finished" string, but that doesn't alter the fundamental problem. How do I make Qt not close the socket until socket_read has finished?
Thanks.
Re: QTcpSocket waiting for write to be read
In Qt part you must leave socket opened until remote part close it.
Try waitForDisconnected() with some huge timeout (default value 30sec - more then enought) before deleting/closing your socket.