From 7c4ae69817ef21da2b45746eaeaae3cd4498cc38 Mon Sep 17 00:00:00 2001 From: winklejo65774 Date: Mon, 15 Oct 2018 16:15:38 +0200 Subject: [PATCH 1/2] Zwischenstand Server- und Clientinitialisierung (Verbindung funktioniert noch nicht) --- .idea/vcs.xml | 6 ++++++ AB1_Aufg2.py => Python-Blockkurs/AB1_Aufg2.py | 0 AB1_Aufg3.py => Python-Blockkurs/AB1_Aufg3.py | 0 AB1_Aufg4.py => Python-Blockkurs/AB1_Aufg4.py | 0 AB1_Aufg5.py => Python-Blockkurs/AB1_Aufg5.py | 0 .../Arbeitsblatt01.pdf | Bin .../Arbeitsblatt02.pdf | Bin .../FirstProgram.py | 0 Pong.py => Python-Blockkurs/Pong.py | 0 README.md => Python-Blockkurs/README.md | 0 .../Tag2_EigenesSpiel.py | 0 ...Tag2_MittelwertAusVariablerAnzahlParameter.py | 0 .../Aufg1_Sockets_Server.py | 15 +++++++++++++++ .../Aufg2_Sockets_Client.py | 8 ++++++++ 14 files changed, 29 insertions(+) create mode 100644 .idea/vcs.xml rename AB1_Aufg2.py => Python-Blockkurs/AB1_Aufg2.py (100%) rename AB1_Aufg3.py => Python-Blockkurs/AB1_Aufg3.py (100%) rename AB1_Aufg4.py => Python-Blockkurs/AB1_Aufg4.py (100%) rename AB1_Aufg5.py => Python-Blockkurs/AB1_Aufg5.py (100%) rename Arbeitsblatt01.pdf => Python-Blockkurs/Arbeitsblatt01.pdf (100%) rename Arbeitsblatt02.pdf => Python-Blockkurs/Arbeitsblatt02.pdf (100%) rename FirstProgram.py => Python-Blockkurs/FirstProgram.py (100%) rename Pong.py => Python-Blockkurs/Pong.py (100%) rename README.md => Python-Blockkurs/README.md (100%) rename Tag2_EigenesSpiel.py => Python-Blockkurs/Tag2_EigenesSpiel.py (100%) rename Tag2_MittelwertAusVariablerAnzahlParameter.py => Python-Blockkurs/Tag2_MittelwertAusVariablerAnzahlParameter.py (100%) create mode 100644 mEIM-Praktikum_Webentwicklung/Aufg1_Sockets_Server.py create mode 100644 mEIM-Praktikum_Webentwicklung/Aufg2_Sockets_Client.py 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/AB1_Aufg2.py b/Python-Blockkurs/AB1_Aufg2.py similarity index 100% rename from AB1_Aufg2.py rename to Python-Blockkurs/AB1_Aufg2.py diff --git a/AB1_Aufg3.py b/Python-Blockkurs/AB1_Aufg3.py similarity index 100% rename from AB1_Aufg3.py rename to Python-Blockkurs/AB1_Aufg3.py diff --git a/AB1_Aufg4.py b/Python-Blockkurs/AB1_Aufg4.py similarity index 100% rename from AB1_Aufg4.py rename to Python-Blockkurs/AB1_Aufg4.py diff --git a/AB1_Aufg5.py b/Python-Blockkurs/AB1_Aufg5.py similarity index 100% rename from AB1_Aufg5.py rename to Python-Blockkurs/AB1_Aufg5.py diff --git a/Arbeitsblatt01.pdf b/Python-Blockkurs/Arbeitsblatt01.pdf similarity index 100% rename from Arbeitsblatt01.pdf rename to Python-Blockkurs/Arbeitsblatt01.pdf diff --git a/Arbeitsblatt02.pdf b/Python-Blockkurs/Arbeitsblatt02.pdf similarity index 100% rename from Arbeitsblatt02.pdf rename to Python-Blockkurs/Arbeitsblatt02.pdf diff --git a/FirstProgram.py b/Python-Blockkurs/FirstProgram.py similarity index 100% rename from FirstProgram.py rename to Python-Blockkurs/FirstProgram.py diff --git a/Pong.py b/Python-Blockkurs/Pong.py similarity index 100% rename from Pong.py rename to Python-Blockkurs/Pong.py diff --git a/README.md b/Python-Blockkurs/README.md similarity index 100% rename from README.md rename to Python-Blockkurs/README.md diff --git a/Tag2_EigenesSpiel.py b/Python-Blockkurs/Tag2_EigenesSpiel.py similarity index 100% rename from Tag2_EigenesSpiel.py rename to Python-Blockkurs/Tag2_EigenesSpiel.py diff --git a/Tag2_MittelwertAusVariablerAnzahlParameter.py b/Python-Blockkurs/Tag2_MittelwertAusVariablerAnzahlParameter.py similarity index 100% rename from Tag2_MittelwertAusVariablerAnzahlParameter.py rename to Python-Blockkurs/Tag2_MittelwertAusVariablerAnzahlParameter.py diff --git a/mEIM-Praktikum_Webentwicklung/Aufg1_Sockets_Server.py b/mEIM-Praktikum_Webentwicklung/Aufg1_Sockets_Server.py new file mode 100644 index 0000000..aecbbfe --- /dev/null +++ b/mEIM-Praktikum_Webentwicklung/Aufg1_Sockets_Server.py @@ -0,0 +1,15 @@ +import socket + +myserver = socket.socket() +hostname = myserver.gethostname() +port = 12345 +myserver.bind((hostname, port)) +myserver.listen() + +while True: + (connection, addr) = myserver.accept() + msg_from_client = myserver.recv(1024) + in_capital_letters = msg_from_client.upper() + connection.send(in_capital_letters.encode('utf-8')) + connection.close() + diff --git a/mEIM-Praktikum_Webentwicklung/Aufg2_Sockets_Client.py b/mEIM-Praktikum_Webentwicklung/Aufg2_Sockets_Client.py new file mode 100644 index 0000000..18cb558 --- /dev/null +++ b/mEIM-Praktikum_Webentwicklung/Aufg2_Sockets_Client.py @@ -0,0 +1,8 @@ +import socket + +myclient = socket.socket() +hostname = myserver.gethostname() +port = 12345 + +myclient.connect((hostname, port)) + From b3d7b7212bd1edfbc35c6f9d72e4459333bb0957 Mon Sep 17 00:00:00 2001 From: winklejo65774 Date: Mon, 15 Oct 2018 17:24:47 +0200 Subject: [PATCH 2/2] Endstand Aufgabe 1 und Aufgabe 2 --- .../Aufg1_Sockets_Client.py | 16 ++++++++++++++++ .../Aufg1_Sockets_Server.py | 14 ++++++-------- .../Aufg2_Sockets_Client.py | 14 ++++++++++++-- .../Aufg2_Sockets_Server.py | 14 ++++++++++++++ 4 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 mEIM-Praktikum_Webentwicklung/Aufg1_Sockets_Client.py create mode 100644 mEIM-Praktikum_Webentwicklung/Aufg2_Sockets_Server.py diff --git a/mEIM-Praktikum_Webentwicklung/Aufg1_Sockets_Client.py b/mEIM-Praktikum_Webentwicklung/Aufg1_Sockets_Client.py new file mode 100644 index 0000000..171e725 --- /dev/null +++ b/mEIM-Praktikum_Webentwicklung/Aufg1_Sockets_Client.py @@ -0,0 +1,16 @@ +import socket + +myclient = socket.socket() +hostname = socket.gethostname() +port = 22445 + +myclient.connect((hostname, port)) + +msg_to_server = input("Aufgabe 1: Bitte geben Sie eine Nachricht ein: ") + +myclient.send(msg_to_server.encode('utf-8')) +converted_msg = myclient.recv(1024) +print("Erhaltener string: ", converted_msg.decode('utf-8')) + +myclient.close() + diff --git a/mEIM-Praktikum_Webentwicklung/Aufg1_Sockets_Server.py b/mEIM-Praktikum_Webentwicklung/Aufg1_Sockets_Server.py index aecbbfe..f674bc3 100644 --- a/mEIM-Praktikum_Webentwicklung/Aufg1_Sockets_Server.py +++ b/mEIM-Praktikum_Webentwicklung/Aufg1_Sockets_Server.py @@ -1,15 +1,13 @@ import socket myserver = socket.socket() -hostname = myserver.gethostname() -port = 12345 +hostname = socket.gethostname() +port = 22445 myserver.bind((hostname, port)) myserver.listen() -while True: - (connection, addr) = myserver.accept() - msg_from_client = myserver.recv(1024) - in_capital_letters = msg_from_client.upper() - connection.send(in_capital_letters.encode('utf-8')) - connection.close() +(connection, addr) = myserver.accept() +msg_from_client = connection.recv(1024).decode('utf-8') +in_capital_letters = msg_from_client.upper() +connection.send(in_capital_letters.encode('utf-8')) diff --git a/mEIM-Praktikum_Webentwicklung/Aufg2_Sockets_Client.py b/mEIM-Praktikum_Webentwicklung/Aufg2_Sockets_Client.py index 18cb558..21a5ad4 100644 --- a/mEIM-Praktikum_Webentwicklung/Aufg2_Sockets_Client.py +++ b/mEIM-Praktikum_Webentwicklung/Aufg2_Sockets_Client.py @@ -1,8 +1,18 @@ import socket myclient = socket.socket() -hostname = myserver.gethostname() -port = 12345 +hostname = socket.gethostname() +port = 33221 myclient.connect((hostname, port)) +while True: + msg_to_server = input("Aufgabe 2: Bitte geben Sie eine Nachricht ein: ") + + if msg_to_server != "STOP": + myclient.send(msg_to_server.encode('utf-8')) + converted_msg = myclient.recv(1024).decode('utf-8') + print("Erhaltener string: ", converted_msg) + else: + myclient.close() + break \ No newline at end of file diff --git a/mEIM-Praktikum_Webentwicklung/Aufg2_Sockets_Server.py b/mEIM-Praktikum_Webentwicklung/Aufg2_Sockets_Server.py new file mode 100644 index 0000000..5f1df19 --- /dev/null +++ b/mEIM-Praktikum_Webentwicklung/Aufg2_Sockets_Server.py @@ -0,0 +1,14 @@ +import socket + +myserver = socket.socket() +hostname = socket.gethostname() +port = 33221 +myserver.bind((hostname, port)) +myserver.listen() + +(connection, addr) = myserver.accept() + +while True: + msg_from_client = connection.recv(1024).decode('utf-8') + in_capital_letters = msg_from_client.upper() + connection.send(in_capital_letters.encode('utf-8')) \ No newline at end of file