Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
4.8.2
-
None
Description
Suppose you have a tcpserver that need to wait for a client command to send an answer something like this:
void CmdSocket::incomingConnection(int handle) { QTcpSocket *socket = new QTcpSocket(this); if (socket->setSocketDescriptor(handle)){ connect(socket,SIGNAL(disconnected()),this,SLOT(socket_disconnected())); connect(socket,SIGNAL(readyRead()),this,SLOT(read_client_data())); } else { socket->deleteLater(); } }
now if a client connects and send nothing readyRead is never fired and the client will stay connected for ever (I waited for several minutes using telnet cli as client). If several clients will do this the socket will not work properly so the bug is major. QTcpSocket should have a timeout option that disconnects the socket if the idle time exceed the given timeout. If one use the sync api in a thread could do something like waitForReadyRead(xxxxx) on connection but without threads this will block the main thread