From 2b26d614c80dadd60acbff92803995f959026acb Mon Sep 17 00:00:00 2001 From: colovicam63900 Date: Tue, 22 Oct 2019 14:44:42 +0200 Subject: [PATCH] Praktikumsblatt 1 --- client.py | 14 +++++++++----- server.py | 13 ++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/client.py b/client.py index 0885fa6..c8ae99e 100755 --- a/client.py +++ b/client.py @@ -4,11 +4,15 @@ s = socket.socket() host = socket.gethostname() port = 4444 -eingabe = input ("Bitte etwas eingeben:") - s.connect((host, port)) -s.send(eingabe.encode("utf-8")) -bytes = s.recv(1024) -print(bytes.decode("utf-8")) + +while True: + + msg = input("Bitte geben Sie einen Text ein:") + s.send(msg.encode("utf-8")) + if msg == "STOPP": + break + bytes = s.recv(1024) + print(bytes.decode("utf-8")) s.close() \ No newline at end of file diff --git a/server.py b/server.py index d628f6e..c390d7e 100755 --- a/server.py +++ b/server.py @@ -8,13 +8,12 @@ s.listen() while True: (connection, addr) = s.accept() - print("Verbindung von ", addr) - data = connection.recv(1024) - data = data.decode("utf-8") - data = data.upper() - print(data) - connection.send(data.encode("utf-8")) + bytes = connection.recv(1024) + msg = bytes.decode("utf-8") + ans = msg.upper() + connection.send(ans.encode("utf-8")) + connection.close() #msg = "Danke für das Vorbeischauen!" # connection.send(msg.encode("utf-8")) - connection.close() \ No newline at end of file + #connection.close() \ No newline at end of file