"""Test double for vpxlog.cpp's VPX_FIFOSOCK: listen on 127.0.0.1:, and on connect stream a real .fifodump so live_render.py can be validated end-to-end WITHOUT the live DOSBox pod. Matches the real topology (vpxlog listens, the Python renderer connects). Streams in chunks with a small delay so the concurrent firmware/socket path is genuinely exercised, then closes (EOF). python feed_sock.py [chunk] [delay_ms] """ import sys, socket, time SRC = sys.argv[1] PORT = int(sys.argv[2]) CHUNK = int(sys.argv[3]) if len(sys.argv) > 3 else 64 << 10 DELAY = (int(sys.argv[4]) if len(sys.argv) > 4 else 5) / 1000.0 data = open(SRC, 'rb').read() ls = socket.socket() ls.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) ls.bind(('127.0.0.1', PORT)) ls.listen(1) print("feed_sock listening on :%d (%d bytes)" % (PORT, len(data)), flush=True) c, _ = ls.accept() print("client connected; streaming", flush=True) sent = 0 for i in range(0, len(data), CHUNK): try: c.sendall(data[i:i + CHUNK]) except OSError: break sent += min(CHUNK, len(data) - i) if DELAY: time.sleep(DELAY) print("streamed %d bytes, closing (EOF)" % sent, flush=True) c.shutdown(socket.SHUT_WR) time.sleep(0.5) c.close(); ls.close()