Skip to content

Instantly share code, notes, and snippets.

@nurikk
Last active October 13, 2020 12:23
Show Gist options
  • Save nurikk/7a69b938b0e8a598d1a2447ada0f9a82 to your computer and use it in GitHub Desktop.
Save nurikk/7a69b938b0e8a598d1a2447ada0f9a82 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import socket
HOST = ''
PORT = 26732
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
try:
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:
print('Connected by', addr)
while True:
data = conn.recv(1024)
if not data:
break
print(data)
except (KeyboardInterrupt, SystemExit):
print("Closing socket")
s.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment