# a simple tcp server import socket,os sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind(('192.168.143.2', 60100)) sock.listen(5) while True: connection,address = sock.accept() buf = connection.recv(1024) if (str(buf)) != "b''": # print("ja") file = open('xmpp_text.txt','w') temp = str(buf, 'utf-8') file.write(str(temp)) # print(file.write(str(buf))) file.close() # else: # print("ist gleich") connection.send(buf) connection.close()