fstream/fstream-util-tcp_to_pipe.py
2021-04-20 16:30:12 +02:00

33 lines
785 B
Python

#!/usr/bin/env python3
import sys
oldexcepthook = sys.excepthook
def newexcepthook(type,value,traceback):
oldexcepthook(type,value,traceback)
#input("Press ENTER to quit.")
sys.excepthook = newexcepthook
import os
p = os.path.join
pUp = os.path.dirname
s = False
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
s = os.path.realpath(sys.executable)
else:
s = os.path.realpath(__file__)
sp = pUp(s)
# script start
import socket
serverAddr = ("127.0.0.1",61921)
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serverSocket.bind(serverAddr)
serverSocket.listen(1)
while True:
connection, address = serverSocket.accept()
connection.settimeout(None)
while True:
data = connection.recv(1000)
if data == b"": break
sys.stdout.buffer.write(data)