#!/usr/bin/env python3 import socket import json HOST = "127.0.0.1" PORT = 8060 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) s.sendall(b"1") data = bytes() while True: recv = s.recv(512) if len(recv) > 0: data += recv else: break out = data.decode() jsout = json.loads(out) print(len(jsout.keys()))