Skip to content

Commit

Permalink
Merge pull request #45 from SalesianosZaragoza/dev_IBT
Browse files Browse the repository at this point in the history
Closes #34
  • Loading branch information
ismaelbernadtello committed Mar 8, 2024
2 parents 678f972 + e2e5a68 commit 95167ea
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions echo-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

HOST = "127.0.0.1"
PORT = 65439
TIEMPO_ESPERA = 100 # segundos
TIEMPO_ESPERA = 20 # segundos

# Diccionario para almacenar los canales y usuarios
channels = {}
Expand Down Expand Up @@ -33,7 +33,14 @@ def handle_connection(conn, addr):
) # Siempre pasa el username actual
handle_command(conn, data, addr, username)
except socket.timeout:
print("Tiempo de espera alcanzado. Cerrando conexión.")
# Si el tiempo de espera se alcanza, cierra la conexión del cliente.
print(
"Tiempo de espera alcanzado. Cerrando conexión del cliente("
+ username
+ ") con dirección IP ("
+ str(addr)
+ ")"
)
break
except ConnectionResetError:
print("La conexión fue restablecida por el cliente.")
Expand Down Expand Up @@ -311,7 +318,7 @@ def establish_connections():
target=server_methods["handle_connection"], args=(conn, addr)
).start()
except KeyboardInterrupt:
print("\nCerrando el servidor...")
print("\nCerrando el servidor de CHAT-JDT...")
sys.exit(0)


Expand Down

0 comments on commit 95167ea

Please sign in to comment.