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

18 lines
416 B

import socket
host = ''
port = 2000
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((host, port))
s.listen()
conn, addr = s.accept()
with conn:
print('Connected by', addr)
while True:
data = conn.recv(1024)
if data == b'exit':
break
print('Received data: ', data)
conn.send(data + b' from server')

Powered by INFORMATICA.FP.EDU.ES.