Add timeout variable to client

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

View File

@ -24,6 +24,7 @@ import threading
import queue
bufferSize = 1000 # buffer size in bytes
timeout = 15 # timeout in seconds
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
class stdoutThread(threading.Thread):
@ -33,7 +34,7 @@ class stdoutThread(threading.Thread):
def run(self):
while True:
data = self.queue.get()
data = self.queue.get(timeout=timeout)
sys.stdout.buffer.write(data)
def listToCommand(lst):
@ -59,7 +60,7 @@ def main():
serverAddr = sys.argv[1].rsplit(":",1)
serverAddr[1] = int(serverAddr[1])
serverAddr = tuple(serverAddr)
connection.settimeout(15)
connection.settimeout(timeout)
connection.connect(serverAddr)
connection.sendall(makePayload(sys.argv[2:]))