Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mestari Yousra
NOTRE_PROJEEET
Commits
b05120bd
Commit
b05120bd
authored
May 30, 2017
by
Mestari Yousra
Browse files
grille coté client
parent
f0358665
Changes
1
Show whitespace changes
Inline
Side-by-side
grille_client.py
0 → 100644
View file @
b05120bd
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment