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.

server.py 381B

5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718
  1. import socket
  2. s = socket.socket()
  3. host = socket.gethostbyname('localhost')
  4. port = 22225
  5. s.bind((host, port))
  6. s.listen()
  7. (connection, addr) = s.accept()
  8. msg = 'test'
  9. while msg != 'STOP':
  10. print('verbindung von ', addr)
  11. bytes = connection.recv(4096)
  12. msg = bytes.decode('utf-8')
  13. msg = msg.upper()
  14. connection.send(msg.encode('utf-8'))
  15. else:
  16. connection.close()