import multiprocessing
import threading
import time

import zmq

from nodes.Broker import Broker


def thread2():
    c = zmq.Context()
    pull = c.socket(zmq.PULL)
    pull.setsockopt(zmq.CONFLATE, 1)
    pull.connect('tcp://127.0.0.1:5555')
    while True:
        print(pull.recv())
        time.sleep(1)


if __name__ == '__main__':
    c = zmq.Context()
    push = c.socket(zmq.PUSH)
    push.bind('tcp://*:5555')
    cnt = 0
    t = threading.Thread(target=thread2)
    t.start()
    for i in range(30):
        cnt += 1
        push.send(str(cnt).encode())
        time.sleep(0.4)




