network: Check for windows platform match

This commit is contained in:
Thomas Adamcik 2014-01-24 19:13:39 +01:00
parent 246e8e3ef8
commit 4453df7594

View File

@ -5,6 +5,7 @@ import gobject
import logging
import re
import socket
import sys
import threading
import pykka
@ -43,9 +44,9 @@ def create_socket():
if has_ipv6:
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
# Explicitly configure socket to work for both IPv4 and IPv6
if (hasattr(socket, 'IPPROTO_IPV6')):
if hasattr(socket, 'IPPROTO_IPV6'):
sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
else:
elif sys.platform == 'win32': # also match 64bit windows.
# Python 2.7 on windows does not have the IPPROTO_IPV6 constant
# Use values extracted from Windows Vista/7/8's header
sock.setsockopt(41, 27, 0)