Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import socket
- import json
- HOST = ''
- PORT = 9090
- with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
- s.bind((HOST, PORT))
- s.listen(4)
- client, addr = s.accept()
- with client:
- print('connected:', addr)
- while True:
- try:
- data = client.recv(16384)
- if not data: continue
- except ConnectionResetError:
- print('connection lost')
- break
- # декодированные данные
- decoded_array = json.loads(data.decode('utf-8'))
- print(decoded_array)
- client.close()
Add Comment
Please, Sign In to add comment