From 4bbd2aed547a5f738897e86d3f87bacae085c3c5 Mon Sep 17 00:00:00 2001 From: berhsi Date: Fri, 26 Jul 2019 21:30:58 +0200 Subject: [PATCH] server-clear.py: backlog changed and timeout added the server has now a limit of 5 connections in socket.listen(). added a timeout from 3 seconds to the connection --- server-clear.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server-clear.py b/server-clear.py index 4fa1712..9dbd393 100755 --- a/server-clear.py +++ b/server-clear.py @@ -50,7 +50,7 @@ def main(): print('Socket created') try: mySocket.bind((HOST, PORT)) - mySocket.listen() + mySocket.listen(5) print('Listen on {} at Port {}'.format(HOST, PORT)) except Exception as e: print('Error: unable to bind and listen') @@ -60,6 +60,7 @@ def main(): try: conn, addr = mySocket.accept() print('Connection from {}:{}'.format(addr[0], addr[1])) + conn.settimeout(3.0) connection_handle(conn) except KeyboardInterrupt: print('\b\bExit')