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:
parent
dc088179f5
commit
4bbd2aed54
1 changed files with 2 additions and 1 deletions
|
@ -50,7 +50,7 @@ def main():
|
||||||
print('Socket created')
|
print('Socket created')
|
||||||
try:
|
try:
|
||||||
mySocket.bind((HOST, PORT))
|
mySocket.bind((HOST, PORT))
|
||||||
mySocket.listen()
|
mySocket.listen(5)
|
||||||
print('Listen on {} at Port {}'.format(HOST, PORT))
|
print('Listen on {} at Port {}'.format(HOST, PORT))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('Error: unable to bind and listen')
|
print('Error: unable to bind and listen')
|
||||||
|
@ -60,6 +60,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
conn, addr = mySocket.accept()
|
conn, addr = mySocket.accept()
|
||||||
print('Connection from {}:{}'.format(addr[0], addr[1]))
|
print('Connection from {}:{}'.format(addr[0], addr[1]))
|
||||||
|
conn.settimeout(3.0)
|
||||||
connection_handle(conn)
|
connection_handle(conn)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\b\bExit')
|
print('\b\bExit')
|
||||||
|
|
Loading…
Reference in a new issue