try local interface discovering on iOS
@@ -42,6 +42,13 @@ import socket
import struct
import threading
+try:
+ import netifaces
+ _use_netifaces = True
+except:
+ _use_netifaces = False
+
+
SEND_ERRORS = {}
@@ -389,6 +396,17 @@ class DiscoverSocket(socket.socket):
``(interface name, interface IP)``
:rtype: list of ``(str, str)``
'''
+ if _use_netifaces:
+ # #addresses on multiple platforms (OS X, Unix, Windows)
+ local_addrs = []
+ # see http://alastairs-place.net/netifaces/
+ for i in netifaces.interfaces():
+ try:
+ local_addrs.extend([(i, d['addr']) for d in netifaces.ifaddresses(i)[netifaces.AF_INET]])
+ except KeyError:
+ pass
+ return local_addrs
+ else:
SIOCGIFCONF = 0x8912
MAXBYTES = 8096
arch = platform.architecture()[0]
