Skip to content
This repository
Browse code

[win32] always use IPv4 sockets on WinXP (because it doesn't support …

…dual-stack IPv4 and IPv6 sockets through IPV6_V6ONLY)
  • Loading branch information...
commit 20093ed56bc73a9e8aac7043aa02526962f2aa4d 1 parent 3a78ad9
Sascha Montellese authored May 20, 2013

Showing 1 changed file with 11 additions and 1 deletion. Show diff stats Hide diff stats

  1. 12  xbmc/network/Network.cpp
12  xbmc/network/Network.cpp
@@ -26,6 +26,9 @@
26 26
 #include "ApplicationMessenger.h"
27 27
 #include "network/NetworkServices.h"
28 28
 #include "utils/log.h"
  29
+#ifdef TARGET_WINDOWS
  30
+#include "utils/SystemInfo.h"
  31
+#endif
29 32
 
30 33
 using namespace std;
31 34
 
@@ -396,6 +399,12 @@ int CreateTCPServerSocket(const int port, const bool bindLocal, const int backlo
396 399
   struct sockaddr_in  *s4;
397 400
   int    sock;
398 401
   bool   v4_fallback = false;
  402
+#ifdef TARGET_WINDOWS
  403
+  // Windows XP and earlier don't support the IPV6_V6ONLY socket option
  404
+  // so always fall back to IPv4 directly to keep old functionality
  405
+  if (CSysInfo::GetWindowsVersion() <= CSysInfo::WindowsVersionWinXP)
  406
+    v4_fallback = true;
  407
+#endif
399 408
 
400 409
 #ifdef WINSOCK_VERSION
401 410
   int yes = 1;
@@ -407,7 +416,8 @@ int CreateTCPServerSocket(const int port, const bool bindLocal, const int backlo
407 416
   
408 417
   memset(&addr, 0, sizeof(addr));
409 418
   
410  
-  if ((sock = socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP)) >= 0)
  419
+  if (!v4_fallback &&
  420
+     (sock = socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP)) >= 0)
411 421
   {
412 422
     // in case we're on ipv6, make sure the socket is dual stacked
413 423
     if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&no, sizeof(no)) < 0)

0 notes on commit 20093ed

Please sign in to comment.
Something went wrong with that request. Please try again.