diff --git a/fstream-client.py b/fstream-client.py index ec3fe94..a77c350 100644 --- a/fstream-client.py +++ b/fstream-client.py @@ -24,10 +24,8 @@ import threading import queue bufferSize = 1000 # buffer size in bytes -serverAddr = ("127.0.0.1",12000) connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - class stdoutThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) @@ -57,11 +55,15 @@ def makePayload(lst): return cmdBytes def main(): + global serverAddr + serverAddr = sys.argv[1].rsplit(":",1) + serverAddr[1] = int(serverAddr[1]) + serverAddr = tuple(serverAddr) connection.settimeout(15) connection.connect(serverAddr) - connection.sendall(makePayload(sys.argv[1:])) + connection.sendall(makePayload(sys.argv[2:])) - if sys.argv[1] == "watch": + if sys.argv[2] == "watch": stdoutThr = stdoutThread() stdoutThr.start() while True: @@ -69,7 +71,7 @@ def main(): if data == b"": return stdoutThr.queue.put(data) - if sys.argv[1] == "broadcast": + if sys.argv[2] == "broadcast": while True: data = sys.stdin.buffer.read(bufferSize) connection.sendall(data)