diff --git a/fstream-util-pipe_to_tcp.py b/fstream-util-pipe_to_tcp.py index f10ca22..e14c034 100644 --- a/fstream-util-pipe_to_tcp.py +++ b/fstream-util-pipe_to_tcp.py @@ -24,12 +24,6 @@ import queue def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) -serverAddr = ("127.0.0.1",61921) -serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -eprint("Opening socket...") -serverSocket.bind(serverAddr) -serverSocket.listen(1) - connection = False connectionLock = threading.Lock() @@ -50,6 +44,22 @@ class pipeThread(threading.Thread): connection = False print(e) +def stringToAddressTuple(addr): + rtn = addr.rsplit(":",1) + rtn[1] = int(rtn[1]) + rtn = tuple(rtn) + return rtn + +def addressTupleToString(addr): + return ":".join(map(str,list(addr))) + +serverAddr = stringToAddressTuple(sys.argv[1]) +serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +eprint("Opening socket...") +serverSocket.bind(serverAddr) +eprint("Serving on " +addressTupleToString(serverAddr)+ "!") +serverSocket.listen(1) + pThread = pipeThread() pThread.start() diff --git a/fstream-util-tcp_to_pipe.py b/fstream-util-tcp_to_pipe.py index 6f0073e..9276cf6 100644 --- a/fstream-util-tcp_to_pipe.py +++ b/fstream-util-tcp_to_pipe.py @@ -22,10 +22,20 @@ import socket def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) -serverAddr = ("127.0.0.1",61921) +def stringToAddressTuple(addr): + rtn = addr.rsplit(":",1) + rtn[1] = int(rtn[1]) + rtn = tuple(rtn) + return rtn + +def addressTupleToString(addr): + return ":".join(map(str,list(addr))) + +serverAddr = stringToAddressTuple(sys.argv[1]) serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) eprint("Opening socket...") serverSocket.bind(serverAddr) +eprint("Serving on " +addressTupleToString(serverAddr)+ "!") serverSocket.listen(1) while True: