| | |
| | | { |
| | | nng_socket sock; |
| | | int rv; |
| | | char buf[1024]; |
| | | |
| | | if ((rv = nng_pub0_open(&sock)) != 0) { |
| | | fatal("nng_pub0_open", rv); |
| | |
| | | } |
| | | 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); |
| | |
| | | } |
| | | |
| | | // 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) { |