import zmq
from threading import Thread
import time

context = zmq.Context.instance()

def client(context):
    print('in thread')
    socket = context.socket(zmq.SUB)
    print('created socket')
    socket.connect('tcp://localhost:5050')
    socket.subscribe(b'slam_map')
    while True:
        print(socket.recv())

def server(context):
    print('in thread')
    socket = context.socket(zmq.PUB)
    print('created socket')
    socket.bind('tcp://*:5050')
    while True:
        socket.send_multipart([b'slam_map', b'Hi'])
        time.sleep(1)

# client_thread = Thread(target=client, args=[context])
server_thread = Thread(target=server, args=[context])
server_thread.start()
# client_thread.start()