|
|
|
|
@ -3,6 +3,7 @@ import select |
|
|
|
|
import socket |
|
|
|
|
import threading |
|
|
|
|
import random |
|
|
|
|
import config |
|
|
|
|
from Queue import Queue, Empty |
|
|
|
|
|
|
|
|
|
MAGIC_PACKET = "" |
|
|
|
|
@ -58,12 +59,17 @@ def get_local_ip(): |
|
|
|
|
s.bind(('<broadcast>', 8888)) |
|
|
|
|
s.setblocking(0) |
|
|
|
|
while True: |
|
|
|
|
result = select.select([s],[],[]) |
|
|
|
|
result = select.select([s],[],[],10) |
|
|
|
|
if len(result[0])==0 : |
|
|
|
|
print "Warning using default local ip" |
|
|
|
|
queue.put([config.LOCAL_IP]) |
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
msg, address = result[0][0].recvfrom(1024) |
|
|
|
|
msg = unicode(msg) |
|
|
|
|
if msg == MAGIC_PACKET: |
|
|
|
|
queue.put(address) |
|
|
|
|
break |
|
|
|
|
queue.put(address) |
|
|
|
|
|
|
|
|
|
queue = Queue() |
|
|
|
|
thread = threading.Thread(target=udp_listening_server) |
|
|
|
|
|