Add timeout variable to client
This commit is contained in:
parent
03ae40f615
commit
329b5629e5
@ -24,6 +24,7 @@ import threading
|
|||||||
import queue
|
import queue
|
||||||
|
|
||||||
bufferSize = 1000 # buffer size in bytes
|
bufferSize = 1000 # buffer size in bytes
|
||||||
|
timeout = 15 # timeout in seconds
|
||||||
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
|
||||||
class stdoutThread(threading.Thread):
|
class stdoutThread(threading.Thread):
|
||||||
@ -33,7 +34,7 @@ class stdoutThread(threading.Thread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while True:
|
while True:
|
||||||
data = self.queue.get()
|
data = self.queue.get(timeout=timeout)
|
||||||
sys.stdout.buffer.write(data)
|
sys.stdout.buffer.write(data)
|
||||||
|
|
||||||
def listToCommand(lst):
|
def listToCommand(lst):
|
||||||
@ -59,7 +60,7 @@ def main():
|
|||||||
serverAddr = sys.argv[1].rsplit(":",1)
|
serverAddr = sys.argv[1].rsplit(":",1)
|
||||||
serverAddr[1] = int(serverAddr[1])
|
serverAddr[1] = int(serverAddr[1])
|
||||||
serverAddr = tuple(serverAddr)
|
serverAddr = tuple(serverAddr)
|
||||||
connection.settimeout(15)
|
connection.settimeout(timeout)
|
||||||
connection.connect(serverAddr)
|
connection.connect(serverAddr)
|
||||||
connection.sendall(makePayload(sys.argv[2:]))
|
connection.sendall(makePayload(sys.argv[2:]))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user