diff options
Diffstat (limited to 'client/client.py')
| -rw-r--r-- | client/client.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/client/client.py b/client/client.py index f87eaba..ea72c27 100644 --- a/client/client.py +++ b/client/client.py @@ -12,19 +12,13 @@ LARGEUR_BLOCK = 10 NB_BLOCKS = 30 LARGEUR_ECRAN = LARGEUR_BLOCK * NB_BLOCKS -def connect(): - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.connect((ip_adress,port)) - return s +s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + def sendData(data): - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.connect((ip_adress,port)) - s.sendall(data.encode('utf-8')) - s.send('#EOF\n'.encode('utf-8')) - received = s.recv(RESP_BUFFER_LENGTH) - s.close() - return received + s.sendto(data,(ip_adress,port)) + received = s.recvfrom(1024) + return received[0] def newGame(): received = sendData('{"type": "new-game"}') @@ -39,6 +33,7 @@ def update(gameId = 1, direction = None): received = sendData(json.dumps(data)) return json.loads(received) + # ---------- END SOCKETS ---------- LARGEUR_BLOCK = 20 |
