From 451668d2524a62845f84cfa8f7297037657972a8 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 7 Nov 2014 15:13:09 +0100 Subject: [PATCH] WinRT: Only set keepalive socket option in certain socket states The keepalive socket can only be set if the socket is not connected (see http://msdn.microsoft.com/en-us/library/ie/windows.networking.sockets.streamsocketcontrol.keepalive) Task-number: QTBUG-38623 Change-Id: Ia40dc66f071a8109538e4be7a8f420de81d5be8d Reviewed-by: Alex Trotsenko Reviewed-by: Leena Miettinen Reviewed-by: Andrew Knight --- src/network/socket/qabstractsocket.cpp | 3 +++ src/network/socket/qnativesocketengine_winrt.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index e843597a96..604214ce8e 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -1882,6 +1882,9 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState \since 4.6 Sets the given \a option to the value described by \a value. + \note On Windows Runtime, QAbstractSocket::KeepAliveOption must be set + before the socket is connected. + \sa socketOption() */ void QAbstractSocket::setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value) diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index cacfe11fea..e60840d651 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -998,7 +998,8 @@ bool QNativeSocketEnginePrivate::setOption(QAbstractSocketEngine::SocketOption o return true; } case QAbstractSocketEngine::KeepAliveOption: { - if (socketType == QAbstractSocket::UdpSocket) + if (socketType == QAbstractSocket::UdpSocket + || socketState != QAbstractSocket::UnconnectedState) return false; boolean keepAlive = v;