Browse Source

Praktikumsblatt 1

master
Amad Colovic 5 years ago
parent
commit
2b26d614c8
2 changed files with 15 additions and 12 deletions
  1. 9
    5
      client.py
  2. 6
    7
      server.py

+ 9
- 5
client.py View File

host = socket.gethostname() host = socket.gethostname()
port = 4444 port = 4444


eingabe = input ("Bitte etwas eingeben:")



s.connect((host, port)) 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() s.close()

+ 6
- 7
server.py View File



while True: while True:
(connection, addr) = s.accept() (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!" #msg = "Danke für das Vorbeischauen!"
# connection.send(msg.encode("utf-8")) # connection.send(msg.encode("utf-8"))
connection.close()
#connection.close()

Loading…
Cancel
Save