# This is a sample Python script. | |||||
# Press ⌃R to execute it or replace it with your code. | |||||
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings. | |||||
import socket | |||||
s = socket.socket() | |||||
host = socket.gethostname() | |||||
port = 12345 | |||||
s.connect((host, port)) | |||||
while True: | |||||
msg = input('Wort eingeben: ') | |||||
if msg != 'STOP': | |||||
s.send(msg.encode('utf-8')) | |||||
bytes = s.recv(1024) | |||||
print(bytes.decode('utf-8')) | |||||
else: | |||||
break | |||||
# See PyCharm help at https://www.jetbrains.com/help/pycharm/ |
import socket | |||||
s = socket.socket() | |||||
host = socket.gethostname() | |||||
port = 12345 | |||||
s.bind((host, port)) | |||||
s.listen() | |||||
while True: | |||||
(connection, addr) = s.accept() | |||||
print('Verbindung von ', addr) | |||||
req = connection.recv(1024) | |||||
msg = req.decode('utf-8') | |||||
if msg != 'STOP': | |||||
msg = msg.upper() | |||||
connection.send(msg.encode('utf-8')) | |||||
else: | |||||
connection.close() | |||||