Created
November 20, 2019 17:06
-
-
Save Magicloud/120357225843eeebcb70205a79f61999 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/python3 | |
import socket | |
import sys | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
server_address = ('0.0.0.0', 10000) | |
sock.bind(server_address) | |
sock.listen(1) | |
while True: | |
connection, client_address = sock.accept() | |
try: | |
while True: | |
data = connection.recv(16) | |
if data: | |
connection.sendall(socket.gethostname().encode()) | |
else: | |
break | |
finally: | |
connection.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment