|
123456789101112131415161718 |
- import socket
-
- s = socket.socket()
- host = socket.gethostbyname('localhost')
- port = 22225
- s.bind((host, port))
- s.listen()
-
- (connection, addr) = s.accept()
- msg = 'test'
- while msg != 'STOP':
- print('verbindung von ', addr)
- bytes = connection.recv(4096)
- msg = bytes.decode('utf-8')
- msg = msg.upper()
- connection.send(msg.encode('utf-8'))
- else:
- connection.close()
|