diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-07-22 15:01:51 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-09-01 12:24:42 (GMT) |
commit | 11cb9c94db6e7c4d494faa071368179e1b4b4b4d (patch) | |
tree | ff2fb89896ce91e6276d7c51e19d4d7338e0606c /src/network/socket | |
parent | 41d8edda671e42c916f45e6eb2716fd76982a121 (diff) | |
download | Qt-11cb9c94db6e7c4d494faa071368179e1b4b4b4d.zip Qt-11cb9c94db6e7c4d494faa071368179e1b4b4b4d.tar.gz Qt-11cb9c94db6e7c4d494faa071368179e1b4b4b4d.tar.bz2 |
Don't use WSAIoctl() to get/set the multicast socket options
According to the MSDN docs, we can just use setsockopt() and
getsockopt() like we do on UNIX, even if we are using Winsock2.
Diffstat (limited to 'src/network/socket')
-rw-r--r-- | src/network/socket/qnativesocketengine_win.cpp | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index d2479f3..5580abc 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -402,19 +402,13 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co n = SO_KEEPALIVE; break; 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; - } + level = IPPROTO_IP; + n = IP_MULTICAST_TTL; + break; case QNativeSocketEngine::MulticastLoopbackOption: - { - unsigned long val = 0; - if (WSAIoctl(socketDescriptor, SIO_MULTIPOINT_LOOPBACK, 0, 0, &val, sizeof(val), 0, 0, 0) == 0) - return val; - return -1; - } + level = IPPROTO_IP; + n = IP_MULTICAST_LOOP; + break; } int v = -1; @@ -476,21 +470,13 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt n = SO_KEEPALIVE; break; 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; - } + level = IPPROTO_IP; + n = IP_MULTICAST_TTL; + break; case QNativeSocketEngine::MulticastLoopbackOption: - { - unsigned long val = v, outval; - if (WSAIoctl(socketDescriptor, SIO_MULTIPOINT_LOOPBACK, &val, sizeof(val), &outval, sizeof(outval), 0, 0, 0) == 0) - return true; - WS_ERROR_DEBUG(WSAGetLastError()); - return false; - } + level = IPPROTO_IP; + n = IP_MULTICAST_LOOP; + break; } if (::setsockopt(socketDescriptor, level, n, (char*)&v, sizeof(v)) != 0) { |