Lösungen der Aufgaben vom Kurs MEIM1 - Web Engineering von Prof. Hofmann
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

protocol-client.py 652B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env python3
  2. import socket
  3. HOST = socket.gethostname()
  4. PORT = 60001
  5. SOCKET = socket.socket()
  6. try:
  7. SOCKET.connect((HOST, PORT))
  8. msg = ""
  9. while True:
  10. msg = input("Your Message: ")
  11. msg = msg.strip()
  12. SOCKET.send(msg.encode("utf-8"))
  13. if msg == "STOP":
  14. break
  15. """while True:
  16. data = SOCKET.recv(16)
  17. print(data)
  18. if data:
  19. recv_msg += data.decode("utf-8")
  20. else:
  21. break"""
  22. data = SOCKET.recv(1024)
  23. print(data.decode("utf-8"))
  24. SOCKET.close()
  25. finally:
  26. SOCKET.close()