diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-07-22 12:26:45 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-09-01 12:24:41 (GMT) |
commit | 41d8edda671e42c916f45e6eb2716fd76982a121 (patch) | |
tree | c5f318806f10fa7b4c6f4f1ca6ef8d84899f3a75 /src/network/socket/qnativesocketengine_win.cpp | |
parent | b7fae53bf12d61274de7d5131ddc15d8f356df59 (diff) | |
download | Qt-41d8edda671e42c916f45e6eb2716fd76982a121.zip Qt-41d8edda671e42c916f45e6eb2716fd76982a121.tar.gz Qt-41d8edda671e42c916f45e6eb2716fd76982a121.tar.bz2 |
Add MulticastTtlOption and MulticastLoopbackOption to QAbstractSocket
These options only make sense and work in QUdpSocket when using
multicasting. Previously, the loopback was set when joining a multicast
group, but the loopback flag is not a per-group flag, it's per socket,
hence this change.
The ability to set the multicast TTL is needed as well, so this is added
as a socket option as well.
Autotest updated to test both.
Diffstat (limited to 'src/network/socket/qnativesocketengine_win.cpp')
-rw-r--r-- | src/network/socket/qnativesocketengine_win.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index d222fd1..d2479f3 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -401,7 +401,14 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co case QNativeSocketEngine::KeepAliveOption: n = SO_KEEPALIVE; break; - case QNativeSocketEngine::MulticastLoopback: + case QNativeSocketEngine::MulticastTtlOption: + { + unsigned long val = 0; + if (WSAIoctl(socketDescriptor, SIO_MULTICAST_SCOPE, 0, 0, &val, sizeof(val), 0, 0 ,0) == 0) + return val; + return -1; + } + case QNativeSocketEngine::MulticastLoopbackOption: { unsigned long val = 0; if (WSAIoctl(socketDescriptor, SIO_MULTIPOINT_LOOPBACK, 0, 0, &val, sizeof(val), 0, 0, 0) == 0) @@ -468,7 +475,15 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt case QNativeSocketEngine::KeepAliveOption: n = SO_KEEPALIVE; break; - case QNativeSocketEngine::MulticastLoopback: + case QNativeSocketEngine::MulticastTtlOption: + { + unsigned long val = v, outval; + if (WSAIoctl(socketDescriptor, SIO_MULTICAST_SCOPE, &val, sizeof(val), &outval, sizeof(outval), 0, 0, 0) == 0) + return true; + WS_ERROR_DEBUG(WSAGetLastError()); + return false; + } + case QNativeSocketEngine::MulticastLoopbackOption: { unsigned long val = v, outval; if (WSAIoctl(socketDescriptor, SIO_MULTIPOINT_LOOPBACK, &val, sizeof(val), &outval, sizeof(outval), 0, 0, 0) == 0) |