blob: 562e36a894a4cf9fed81360416f930e74344bcf4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import socket
import json
class SendDictTcp(object):
def __init__(self, host, port):
self.host = host
self.port = port
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((self.host, self.port))
self.buffer_size = 1024
def send(self, msg):
self.sock.send(json.dumps(msg))
return self.sock.recv(self.buffer_size)
|