fstream/fstream-util-tcp_to_pipe.py

33 lines
783 B
Python
Raw Normal View History

#!/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()
2021-04-21 10:32:52 +00:00
connection.settimeout(15)
while True:
data = connection.recv(1000)
2021-04-15 18:40:43 +00:00
if data == b"": break
sys.stdout.buffer.write(data)