Skip to content

Instantly share code, notes, and snippets.

@xcooper
Created July 11, 2022 07:00
Show Gist options
  • Save xcooper/abf601555180dabea1b48fb80244d47e to your computer and use it in GitHub Desktop.
Save xcooper/abf601555180dabea1b48fb80244d47e to your computer and use it in GitHub Desktop.
wait on socket and redirect to stdout
import socket, os, sys
addr = ("", 4444)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(addr)
s.listen(1)
conn, addr = s.accept()
while 1:
data = conn.recv(1024)
if not data: break
sys.stdout.write(data)
s.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment