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 <alex1973tr@gmail.com>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Reviewed-by: Andrew Knight <andrew.knight@theqtcompany.com>
This commit is contained in:
Oliver Wolff 2014-11-07 15:13:09 +01:00
parent 8920200c97
commit 451668d252
2 changed files with 5 additions and 1 deletions

View File

@ -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)

View File

@ -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;