Mise en constante du buffer

This commit is contained in:
Fred Z 2018-02-25 22:36:13 +01:00
parent a825bb2712
commit 7cbf894e2e
2 changed files with 4 additions and 3 deletions

View File

@ -17,7 +17,7 @@ if len(sys.argv) < 3:
HOST = sys.argv[1]
PORT = int(sys.argv[2])
RECV_BUFFER = 1024
BUFFER = 1024
MSG_SERVER_CONNECTED = "Serveur connecté @{}:{}"
MSG_CLOSE_CONNECTION = "Connexion vers [{}:{}] fermée"
@ -35,7 +35,7 @@ while msg_a_envoyer != bytes(STOP_COMMAND, 'utf8'):
msg_a_envoyer = msg_a_envoyer.encode()
# On envoie le message
SERVER_CONNECTION.send(msg_a_envoyer)
msg_recu = SERVER_CONNECTION.recv(RECV_BUFFER)
msg_recu = SERVER_CONNECTION.recv(BUFFER)
print(msg_recu.decode()) # Là encore, peut planter s'il y a des accents
SERVER_CONNECTION.close()

View File

@ -11,6 +11,7 @@ import select
HOST = ''
PORT = 12800
BUFFER = 1024
MSG_NEW_CLIENT = "Nouveau client: {}"
MSG_CLIENT_ID = "Client[{}] {}"
@ -65,7 +66,7 @@ while server_on:
for client in read_client_list:
# Client est de type socket
msg_recu = client.recv(1024)
msg_recu = client.recv(BUFFER)
# Peut planter si le message contient des caractères spéciaux
msg_recu = msg_recu.decode()