O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

What just happened?

Since more than one connection may be pending, we use hasPendingConnections() to determine whether there is at least one more pending connection. Each one is then handled in the iteration of the while loop. To get a pending connection of the QTcpSocket type, we call nextPendingConnection() and add this connection to a private vector called m_clients, which holds all active connections. In the next line, as there is now at least one connection, we enable the button that allows all connections to be closed. The slot connected to the button's click() signal will call QTcpSocket::close() on each single connection. When a connection is closed, its socket emits a disconnected() signal. We connect this signal to our removeConnection() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required