def main(args): context = zmq.Context() socket = context.socket(zmq.REQ) data = ba.parse_address(args.address) socket.connect('tcp://%s:%s' % (ba.get_host_ip(data.get('domain')), args.port)) socket.send(ba.dumps(data)) response = socket.recv() print response
def start_server(host, port, addresses): """ Starts the bitcoinaddress server. """ context = zmq.Context() socket = context.socket(zmq.REP) address = 'tcp://%s:%s' % (host, port) socket.bind(address) print 'runs on %s' % address while True: data = socket.recv() data = json.loads(data) socket.send( ba.dumps({'address': addresses.get(data.get('name'), None)}))