From faa0fa5553a02dc4b5fe99081fca79a3d58b60b0 Mon Sep 17 00:00:00 2001 From: hartwigja62500 Date: Mon, 15 Oct 2018 16:52:39 +0200 Subject: [PATCH] 1.termin --- Prakt1_Socket.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Prakt1_Socket.py diff --git a/Prakt1_Socket.py b/Prakt1_Socket.py new file mode 100644 index 0000000..7840e35 --- /dev/null +++ b/Prakt1_Socket.py @@ -0,0 +1,19 @@ +import socket + +s = socket.socket() +host = socket.gethostname() +port = 21345 +s.bind((host, port)) +s.listen() + +while True: + (connection, addr) = s.accept() + print('Verbindung von ', addr) + msg = 'Server sagt Hallo' + connection.send(msg.encode('utf-8')) + msg = connection.recv(1024) + + #connection.send(msg) + msg = msg.decode('utf-8') + print(msg) + connection.close() \ No newline at end of file