You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
438 B
Python

# создание сокета, сервер
import socket
# https://docs.python.org/3/library/socket.html
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("127.0.0.1", 10001)) # max port 65535
sock.listen(socket.SOMAXCONN)
conn, addr = sock.accept()
while True:
data = conn.recv(1024)
if not data:
break
# process data
print(data.decode("utf8"))
conn.close()
sock.close()