Add timeout variable to server

This commit is contained in:
Fierelier 2021-04-14 18:52:47 +02:00
parent 329b5629e5
commit e1c8518df2

View File

@ -36,6 +36,7 @@ serverAddr = ("127.0.0.1",12000)
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
bufferSize = 1000 # Buffer size in bytes bufferSize = 1000 # Buffer size in bytes
timeout = 15 # How long to wait for a connection to respond before timing out?
maxClients = 100 # How many clients can be connected at maximum? maxClients = 100 # How many clients can be connected at maximum?
maxClientsPerIP = 5 # How many clients can be connected at maximum, per IP? maxClientsPerIP = 5 # How many clients can be connected at maximum, per IP?
maxAccumulatedData = 20*1000*1000 # How much data can be in an outbound thread's queue at maximum before the connection is closed? maxAccumulatedData = 20*1000*1000 # How much data can be in an outbound thread's queue at maximum before the connection is closed?
@ -262,6 +263,7 @@ def main():
while True: while True:
connection, address = serverSocket.accept() connection, address = serverSocket.accept()
connection.settimeout(timeout)
connection.settimeout(15) connection.settimeout(15)
with connectionsLock: with connectionsLock: