# Collection of code snippets by Arne Vajhøj 
# (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import zmq

TOPIC = '1234'

def test(addr):
    ctx = zmq.Context()
    s = ctx.socket(zmq.SUB)
    s.connect(addr)
    s.subscribe(TOPIC)
    for i in range(3):
        respmsg = s.recv_string()
        respmsg = respmsg[len(TOPIC):]
        print('Python client : ' + respmsg)

test("tcp://localhost:10001")
test("tcp://localhost:10002")
test("tcp://localhost:10003")
test("tcp://localhost:10004")
test("tcp://localhost:10005")
test("tcp://localhost:10006")
