import socket s = socket.socket() s.connect(('192.168.0.46', 50007)) message = input('? ') while message != 'Z': s.send(bytes(message,'utf8')) message = input('? ') s.send(b'Z') s.close()