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
This commit is contained in:
berhsi 2019-07-26 21:30:58 +02:00
parent dc088179f5
commit 4bbd2aed54

View file

@ -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')