Last active
October 13, 2020 12:23
-
-
Save nurikk/7a69b938b0e8a598d1a2447ada0f9a82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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