diff options
author | montellese <montellese@xbmc.org> | 2013-05-20 10:24:23 +0200 |
---|---|---|
committer | montellese <montellese@xbmc.org> | 2013-05-20 10:24:23 +0200 |
commit | 20093ed56bc73a9e8aac7043aa02526962f2aa4d (patch) | |
tree | e3727584992a96970aad4fad6ac8045b70615464 | |
parent | 3a78ad9d1415305eaf57a18733de831acc5d1e28 (diff) |
[win32] always use IPv4 sockets on WinXP (because it doesn't support dual-stack IPv4 and IPv6 sockets through IPV6_V6ONLY)
-rw-r--r-- | xbmc/network/Network.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/xbmc/network/Network.cpp b/xbmc/network/Network.cpp index e5684bb17b..9795a5410a 100644 --- a/xbmc/network/Network.cpp +++ b/xbmc/network/Network.cpp @@ -26,6 +26,9 @@ #include "ApplicationMessenger.h" #include "network/NetworkServices.h" #include "utils/log.h" +#ifdef TARGET_WINDOWS +#include "utils/SystemInfo.h" +#endif using namespace std; @@ -396,6 +399,12 @@ int CreateTCPServerSocket(const int port, const bool bindLocal, const int backlo struct sockaddr_in *s4; int sock; bool v4_fallback = false; +#ifdef TARGET_WINDOWS + // Windows XP and earlier don't support the IPV6_V6ONLY socket option + // so always fall back to IPv4 directly to keep old functionality + if (CSysInfo::GetWindowsVersion() <= CSysInfo::WindowsVersionWinXP) + v4_fallback = true; +#endif #ifdef WINSOCK_VERSION int yes = 1; @@ -407,7 +416,8 @@ int CreateTCPServerSocket(const int port, const bool bindLocal, const int backlo memset(&addr, 0, sizeof(addr)); - if ((sock = socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP)) >= 0) + if (!v4_fallback && + (sock = socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP)) >= 0) { // in case we're on ipv6, make sure the socket is dual stacked if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&no, sizeof(no)) < 0) |