From 482071b44a1b9011ea4097e21e2266e70d992131 Mon Sep 17 00:00:00 2001 From: holzschuhke56905 Date: Tue, 15 Oct 2019 15:23:23 +0200 Subject: [PATCH] Version_1_final --- .idea/vcs.xml | 6 ++++++ Client.py | 24 +++++++++++++++++------- Server.py | 21 +++++++++++++++++---- 3 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Client.py b/Client.py index 61985ac..ec03dcf 100644 --- a/Client.py +++ b/Client.py @@ -2,17 +2,27 @@ import socket SOCKET = socket.socket() HOST = socket.gethostname() -PORT = 45677 - - - -# Eingabe -eingabe = input("Eingabe: ") +PORT = 45670 # Verbindung zum Server SOCKET.connect((HOST, PORT)) -SOCKET.send(eingabe.encode("utf-8")) + +while True: + eingabe = input("Eingabe: ") + msg = eingabe.encode("utf-8") + + SOCKET.send(msg) + + + if eingabe.upper() == "STOP": + SOCKET.close() + break + + msg = SOCKET.recv(1024) + msg = msg.decode("utf-8") + + print(msg) diff --git a/Server.py b/Server.py index 7470f4d..ea18e3d 100644 --- a/Server.py +++ b/Server.py @@ -2,18 +2,31 @@ import socket SOCKET = socket.socket() HOST = socket.gethostname() -PORT = 45677 +PORT = 45670 SOCKET.bind((HOST, PORT)) SOCKET.listen() +while True: + (connection, addr) = SOCKET.accept() -(connection, addr) = SOCKET.accept() + print("Server: " + addr[0] + " Port: " + str(addr[1])) -eingabe = connection.recv(1024) -print(eingabe.decode) + eingabe = connection.recv(1024) + + msg = eingabe.decode("utf-8") + msg = msg.upper() + + print(msg) + + if msg == "STOP": + connection.close() + SOCKET.close() + break + + connection.send(msg.encode("utf-8")) SOCKET.close() \ No newline at end of file