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

Example network code: Multicast and Broadcast don't close their UDP socket and can fail upon subsequent run.

    XMLWordPrintable

    Details

    • Platform/s:
      Android

      Description

      Example code in 4 network example apps fail to close their UDP socket.
      (this pattern is repeated in multicast send/receiver and broadcast sender/receiver examples).

      Such that on some platforms the code will run once.... but fail on subsequent attempts (until the socket possibly resets itself).

      Current code in ......\Qt\Examples\Qt-5.9.1\network\multicastreceiver\receiver.cpp:

      // the following will cause a failure on most platforms (not a clean shutdown of socket), it closes the app, not the socket:
      connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));

      The FIX (is to change the SLOT and add a cleanup function):

      connect(quitButton, SIGNAL(clicked()), this, SLOT(cleanup())); 

      // Adding:
      void Receiver::cleanup()
      {
         // implement a clean exit, 1st, close UDP socket on the way out, so it can be immediately reopened (if desired).
         udpSocket->close();          
        
         // then close the app:
         close();
      {color:#ff0000}}

      This pattern is repeated in (...\Qt\Examples\Qt-5.9.1\network\ {multicastreceiver, multicastsender, broadcastreceiver & broadcastsender} all need to be fixed.  

      So a *::cleanup() which closes the UDP socket needs to be added to all these examples... 
      I would also check all the other network samples for this repeated pattern... as it seems pervasive.

        Attachments

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

          Activity

            People

            • Assignee:
              tpochep Timur Pocheptsov
              Reporter:
              jakekirk jakekirk
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes