def _inet_pton_win(address_family, ip_string):
 addr = sockaddr()
 addr.sa_family = address_family
 addr_size = ctypes.c_int(ctypes.sizeof(addr))
 str_to_addr = ctypes.windll.ws2_32.WSAStringToAddressA
 if (str_to_addr(ip_string, address_family, None, ctypes.byref(addr), ctypes.byref(addr_size)) != 0):
  raise socket.error(ctypes.FormatError())
 if (address_family == socket.AF_INET):
  return ctypes.string_at(addr.ipv4_addr, 4)
 if (address_family == socket.AF_INET6):
  return ctypes.string_at(addr.ipv6_addr, 16)
 raise socket.error('unknown address family')

def _inet_pton_win ( address_family , ip_string ) : addr = sockaddr ( ) addr . sa_family = address_family addr_size = ctypes . c_int ( ctypes . sizeof ( addr ) ) str_to_addr = ctypes . windll . ws2_32 . WSAStringToAddressA if ( str_to_addr ( ip_string , address_family , None , ctypes . byref ( addr ) , ctypes . byref ( addr_size ) ) != 0 ) : raise socket . error ( ctypes . FormatError ( ) ) if ( address_family == socket . AF_INET ) : return ctypes . string_at ( addr . ipv4_addr , 4 ) if ( address_family == socket . AF_INET6 ) : return ctypes . string_at ( addr . ipv6_addr , 16 ) raise socket . error ( 'unknown address family' )
window specific version of inet_pton based on: URL .