import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind(('192.168.1.178', 9200)) sock.listen(5) while True: sock_cli, addr = sock.accept() with open('./a.txt','r') as f: byte = f.read(1024) sock_cli.sendall(byte) # with open('./a.txt','w') as f: # f.write('lllllllllllllll')