Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-26895

QTcpSocket inactivity timeout

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 4.8.2
    • Network: Sockets
    • 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

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            shkearns Shane Kearns
            drakkan Nicola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes