Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.7.1, 5.9.1
-
None
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.