From 4620b0fc7a48c643400a42eb9e9cc0a82ad0be9a Mon Sep 17 00:00:00 2001 From: Robin Helgelin Date: Wed, 21 Apr 2010 12:14:02 +0200 Subject: Keep support for maximum pending connections in derived QTcpServer By adding a new function to the class QTcpServer it's now possible to extend QTcpserver functionality with for instance SSL capabilities and still keep the support for maximum pending connections. Task-number: QTBUG-1875 Reviewed-by: Peter Hartmann Reviewed-by: Markus Goetz Merge-Request: 568 --- src/network/socket/qtcpserver.cpp | 15 +++++++++++++++ src/network/socket/qtcpserver.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp index 932126d..a259eee 100644 --- a/src/network/socket/qtcpserver.cpp +++ b/src/network/socket/qtcpserver.cpp @@ -572,6 +572,21 @@ void QTcpServer::incomingConnection(int socketDescriptor) QTcpSocket *socket = new QTcpSocket(this); socket->setSocketDescriptor(socketDescriptor); + addPendingConnection(socket); +} + +/*! + This function is called by QTcpServer::incomingConnection() + to add a socket to the list of pending incoming connections. + + \note Don't forget to call this member from reimplemented + incomingConnection() if you do not want to break the + Pending Connections mechanism. + + \sa incomingConnection() +*/ +void QTcpServer::addPendingConnection(QTcpSocket* socket) +{ d_func()->pendingConnections.append(socket); } diff --git a/src/network/socket/qtcpserver.h b/src/network/socket/qtcpserver.h index 7aebffe..b206678 100644 --- a/src/network/socket/qtcpserver.h +++ b/src/network/socket/qtcpserver.h @@ -93,6 +93,7 @@ public: protected: virtual void incomingConnection(int handle); + void addPendingConnection(QTcpSocket* socket); Q_SIGNALS: void newConnection(); -- cgit v0.12