summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qtcpserver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/socket/qtcpserver.cpp')
-rw-r--r--src/network/socket/qtcpserver.cpp38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp
index b41d207947..914c14877e 100644
--- a/src/network/socket/qtcpserver.cpp
+++ b/src/network/socket/qtcpserver.cpp
@@ -160,6 +160,23 @@ QNetworkProxy QTcpServerPrivate::resolveProxy(const QHostAddress &address, quint
/*! \internal
*/
+void QTcpServerPrivate::configureCreatedSocket()
+{
+#if defined(Q_OS_UNIX)
+ // Under Unix, we want to be able to bind to the port, even if a socket on
+ // the same address-port is in TIME_WAIT. Under Windows this is possible
+ // anyway -- furthermore, the meaning of reusable on Windows is different:
+ // it means that you can use the same address-port for multiple listening
+ // sockets.
+ // Don't abort though if we can't set that option. For example the socks
+ // engine doesn't support that option, but that shouldn't prevent us from
+ // trying to bind/listen.
+ socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1);
+#endif
+}
+
+/*! \internal
+*/
void QTcpServerPrivate::readNotification()
{
Q_Q(QTcpServer);
@@ -205,6 +222,9 @@ void QTcpServerPrivate::readNotification()
QTcpServer::QTcpServer(QObject *parent)
: QObject(*new QTcpServerPrivate, parent)
{
+#if defined(QTCPSERVER_DEBUG)
+ qDebug("QTcpServer::QTcpServer(%p)", parent);
+#endif
}
/*!
@@ -218,6 +238,9 @@ QTcpServer::QTcpServer(QObject *parent)
*/
QTcpServer::~QTcpServer()
{
+#if defined(QTCPSERVER_DEBUG)
+ qDebug("QTcpServer::~QTcpServer()");
+#endif
close();
}
@@ -226,6 +249,9 @@ QTcpServer::~QTcpServer()
QTcpServer::QTcpServer(QTcpServerPrivate &dd, QObject *parent)
: QObject(dd, parent)
{
+#if defined(QTCPSERVER_DEBUG)
+ qDebug("QTcpServer::QTcpServer(QTcpServerPrivate == %p, parent == %p)", &dd, parent);
+#endif
}
/*!
@@ -275,17 +301,7 @@ bool QTcpServer::listen(const QHostAddress &address, quint16 port)
if (addr.protocol() == QAbstractSocket::AnyIPProtocol && proto == QAbstractSocket::IPv4Protocol)
addr = QHostAddress::AnyIPv4;
-#if defined(Q_OS_UNIX)
- // Under Unix, we want to be able to bind to the port, even if a socket on
- // the same address-port is in TIME_WAIT. Under Windows this is possible
- // anyway -- furthermore, the meaning of reusable on Windows is different:
- // it means that you can use the same address-port for multiple listening
- // sockets.
- // Don't abort though if we can't set that option. For example the socks
- // engine doesn't support that option, but that shouldn't prevent us from
- // trying to bind/listen.
- d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1);
-#endif
+ d->configureCreatedSocket();
if (!d->socketEngine->bind(addr, port)) {
d->serverSocketError = d->socketEngine->error();