Commit b05120bd authored by Mestari Yousra's avatar Mestari Yousra
Browse files

grille coté client

parent f0358665
import zmq
context = zmq.Context()
# Socket to talk to server
socket = context.socket(zmq.DEALER)
socket.connect("tcp://147.250.9.87:5555")
def grille_client(J):
for i in range(5):
#verifier que les bateaux sont bien mis
empty,validation=socket.recv_multipart()
while validation.decode() != "ok":
#question de la tete
empty,reponse=socket.recv_multipart()
print(reponse.decode())
#reponse de la tete
position_avant=input()
socket.send_multipart([b'',position_avant.encode()])
empty,reponse=socket.recv_multipart()
#tete illegale
if reponse.decode()=="Cette case est deja occupee":
print(reponse.decode())
empty,validation=socket.recv_multipart()
#tete legale
else:
#question de la queue
print(reponse.decode())
#reponse de la queue
position_queue=input()
socket.send_multipart([b'',position_queue.encode()])
empty,reponse=socket.recv_multipart()
#queue illegale
if reponse.decode()=="Cette combinaison n'est pas valable":
print(reponse.decode())
empty,validation=socket.recv_multipart()
#queue legale
else:
empty,validation=socket.recv_multipart()
return
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment