/* Collection of code snippets by Arne Vajhøj */
/* (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) */
#include <stdio.h>
#include <string.h>

#include <czmq.h>

#define TOPIC "1234"

void test(const char *addr)
{   
    zsock_t *s;
    char *respmsg, *respmsg2;
    int n;
    s = zsock_new_sub(addr, "");
    zsock_set_subscribe(s, TOPIC);
    n = 0;
    while(n < 3)
    {
        respmsg = zstr_recv(s);
        respmsg2 = respmsg + strlen(TOPIC) + 1;
        printf("C (high) client : %s\n", respmsg2);
        n++;
    }
    zstr_free(&respmsg);
    zsock_destroy(&s);
}

int main(void)
{
    test("tcp://localhost:10001");
    test("tcp://localhost:10002");
    test("tcp://localhost:10003");
    test("tcp://localhost:10004");
    test("tcp://localhost:10005");
    test("tcp://localhost:10006");
    return 0;
}
