currently there is no subscription forwarding, so basically the pub socket won't notice the subscriptions in anyway. Subscription Filtering is done as prefix filtering so if you prefix you message on the server side with "sub1" only the sockets that subscribed to "sub1", "sub", "su", "s" or "" will receive the message all others will silently drop it.
On 13.08.2014 22:47, John Carneiro wrote:
It seems like this line from the example: nn_setsockopt (sock, NN_SUB, NN_SUB_SUBSCRIBE, "", 0) could easily be instead something like this to subscribe to a subscription type of "sub1": const char* subType = "sub1"; nn_setsockopt (sock, NN_SUB, NN_SUB_SUBSCRIBE, subType, strlen(subType) + 1) and I would assume you could read this string on the publishing server like this char subType[100]; getsockopt(sock, NN_SOL_SOCKET, NN_PROTOCOL, &subType, sizeof(subType));
int server (const char *url) { int sock = nn_socket (AF_SP, NN_PUB); assert (sock >= 0); assert (nn_bind (sock, url) >= 0); while (1) { char *d = date(); // prefix with sub1 somehow :D int sz_d = strlen(d) + 1; // '\0' too printf ("SERVER: PUBLISHING DATE %s\n", d); int bytes = nn_send (sock, d, sz_d, 0); assert (bytes == sz_d); const char *test = "sub2test123"; int sz_test = strlen(test) + 1; // '\0' too bytes = nn_send (sock, test, sz_test, 0); assert (bytes == sz_test); sleep(1); } return nn_shutdown (sock, 0); }