wangzhengquan
2020-06-15 73866a4c527cbdf726c5fd824526d5657d0e15ee
test/nng/pubsub.c
@@ -32,6 +32,7 @@
{
        nng_socket sock;
        int rv;
        char buf[1024];
        if ((rv = nng_pub0_open(&sock)) != 0) {
                fatal("nng_pub0_open", rv);
@@ -41,8 +42,9 @@
        }
        for (;;) {
                char *d = date();
                snprintf(buf, 1024, "time:%s", d);
                printf("SERVER: PUBLISHING DATE %s\n", d);
                if ((rv = nng_send(sock, d, strlen(d) + 1, 0)) != 0) {
                if ((rv = nng_send(sock, buf, strlen(buf) + 1, 0)) != 0) {
                        fatal("nng_send", rv);
                }
                sleep(1);
@@ -60,7 +62,7 @@
        }
        // subscribe to everything (empty means all topics)
        if ((rv = nng_setopt(sock, NNG_OPT_SUB_SUBSCRIBE, "", 0)) != 0) {
        if ((rv = nng_setopt(sock, NNG_OPT_SUB_SUBSCRIBE, "nnnnnnnnn", 0)) != 0) {
                fatal("nng_setopt", rv);
        }
        if ((rv = nng_dial(sock, url, NULL, 0)) != 0) {