diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index d74a717d93..91f10a0127 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -360,6 +360,19 @@ \value MulticastLoopbackOption Set this to 1 to enable the IP_MULTICAST_LOOP (multicast loopback) socket option. + \value TypeOfServiceOption This option is not supported on Windows. This maps to to the IP_TOS socket option. Possible values are: + \table + \header \o Value \o Description + \row \o 224 \o Network control + \row \o 192 \o Internetwork control + \row \o 160 \o CRITIC/ECP + \row \o 128 \o Flash override + \row \o 96 \o Flash + \row \o 64 \o Immediate + \row \o 32 \o Priority + \row \o 0 \o Routine + \endtable + \sa QAbstractSocket::setSocketOption(), QAbstractSocket::socketOption() */ @@ -1805,6 +1818,10 @@ void QAbstractSocket::setSocketOption(QAbstractSocket::SocketOption option, cons case MulticastLoopbackOption: d_func()->socketEngine->setOption(QAbstractSocketEngine::MulticastLoopbackOption, value.toInt()); break; + + case TypeOfServiceOption: + d_func()->socketEngine->setOption(QAbstractSocketEngine::TypeOfServiceOption, value.toInt()); + break; } } @@ -1841,6 +1858,10 @@ QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option) case MulticastLoopbackOption: ret = d_func()->socketEngine->option(QAbstractSocketEngine::MulticastLoopbackOption); break; + + case TypeOfServiceOption: + ret = d_func()->socketEngine->option(QAbstractSocketEngine::TypeOfServiceOption); + break; } if (ret == -1) return QVariant(); diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h index ee910e3b33..e3c27e34b0 100644 --- a/src/network/socket/qabstractsocket.h +++ b/src/network/socket/qabstractsocket.h @@ -113,7 +113,8 @@ public: LowDelayOption, // TCP_NODELAY KeepAliveOption, // SO_KEEPALIVE MulticastTtlOption, // IP_MULTICAST_TTL - MulticastLoopbackOption // IP_MULTICAST_LOOPBACK + MulticastLoopbackOption, // IP_MULTICAST_LOOPBACK + TypeOfServiceOption //IP_TOS }; enum BindFlag { DefaultForPlatform = 0x0, diff --git a/src/network/socket/qabstractsocketengine_p.h b/src/network/socket/qabstractsocketengine_p.h index a8be98a0cf..e58cc5ab95 100644 --- a/src/network/socket/qabstractsocketengine_p.h +++ b/src/network/socket/qabstractsocketengine_p.h @@ -99,7 +99,8 @@ public: LowDelayOption, KeepAliveOption, MulticastTtlOption, - MulticastLoopbackOption + MulticastLoopbackOption, + TypeOfServiceOption }; virtual bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol) = 0; diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 09aed255d6..c0a55b9a26 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -251,6 +251,12 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co n = IP_MULTICAST_LOOP; } break; + case QNativeSocketEngine::TypeOfServiceOption: + if (socketProtocol == QAbstractSocket::IPv4Protocol) { + level = IPPROTO_IP; + n = IP_TOS; + } + break; } int v = -1; @@ -352,6 +358,12 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt n = IP_MULTICAST_LOOP; } break; + case QNativeSocketEngine::TypeOfServiceOption: + if (socketProtocol == QAbstractSocket::IPv4Protocol) { + level = IPPROTO_IP; + n = IP_TOS; + } + break; } return ::setsockopt(socketDescriptor, level, n, (char *) &v, sizeof(v)) == 0; diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index 247de01072..b9a9c613d4 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -422,6 +422,9 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co n = IP_MULTICAST_LOOP; } break; + case QNativeSocketEngine::TypeOfServiceOption: + return -1; + break; } int v = -1; @@ -502,6 +505,9 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt n = IP_MULTICAST_LOOP; } break; + case QNativeSocketEngine::TypeOfServiceOption: + return false; + break; } if (::setsockopt(socketDescriptor, level, n, (char*)&v, sizeof(v)) != 0) {