Last active
January 7, 2021 19:27
-
-
Save apolzek/d0c07e6c05d8cf50b74e5d36adb27e14 to your computer and use it in GitHub Desktop.
Listen port Python3
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
import socket | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind(('0.0.0.0', 50000)) | |
s.listen(1) | |
conn, addr = s.accept() | |
while 1: | |
data = conn.recv(1024) | |
print(data) | |
if not data: | |
break | |
conn.sendall(data) | |
conn.close() | |
#nc -v localhost 50000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment