Browse Source

Handling of connection reset error

feature/balanceutils
klonfish 8 years ago committed by klonfish
parent
commit
4a9238c110
  1. 37
      wii-pair/daemon.py

37
wii-pair/daemon.py

@ -173,26 +173,29 @@ try: @@ -173,26 +173,29 @@ try:
conn, addr = s.accept()
while True:
m = conn.recv(1)
try:
m = conn.recv(1)
if len(m) == 0:
conn.close()
break
if len(m) == 0:
conn.close()
break
r = b''
for w in wiis:
if w.pos_x is None:
v = -128
else:
v = int(round(w.pos_x*100))
r += struct.pack('b', v)
if w.pos_y is None:
v = -128
else:
v = int(round(w.pos_y*100))
r += struct.pack('b', v)
r = b''
for w in wiis:
if w.pos_x is None:
v = -128
else:
v = int(round(w.pos_x*100))
r += struct.pack('b', v)
if w.pos_y is None:
v = -128
else:
v = int(round(w.pos_y*100))
r += struct.pack('b', v)
conn.send(r)
conn.send(r)
except ConnectionResetError:
continue
except (KeyboardInterrupt, SystemExit):
t1.stop = True
t2.stop = True

Loading…
Cancel
Save