[nanomsg] Re: about SUB/PUB protocol

  • From: Garrett D'Amore <garrett@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Mon, 5 Dec 2016 07:32:58 -0800

Sounds like a possible bug.  Can you verify with a minimal test case?  
(Programs are supposed to allow multiple subscriptions and only receive 
messages they have subscribed to.  Btw using sizeof on your subscriptions means 
that the message tags must be null terminated.  You probably want strlen() 
instead. 

Sent from my iPhone

On Dec 2, 2016, at 7:03 AM, Andris (Redacted sender "andrlv" for DMARC) 
<dmarc-noreply@xxxxxxxxxxxxx> wrote:

 
Hello!

I have one question about PUB/SUB protocol in nanomsg.
If I have one Publisher, that send messages:
TAG1 Message data 1
TAG2 Message data 2
TAG3 Message data 3
....
TAGN Message data n

Is it possible to subscribe on subscriber side to more then to one tag?

I try subscribe using:
assert (nn_setsockopt (sock, NN_SUB, NN_SUB_SUBSCRIBE, "TAG1", 
sizeof("TAG1")) >= 0);
assert (nn_setsockopt (sock, NN_SUB, NN_SUB_SUBSCRIBE, "TAG2", 
sizeof("TAG2")) >= 0);

and I receive only
TAG1 Message data 1
TAG2 Message data 2
messages. That is what I want. But... I if publisher send messages like these
JAG1 ......
PAG1 ......
SAG2 ......
receiver who is subscribed to TAG1 and TAG2 messages, receive these messages 
too.
 
This is a bug or user can subscribe only to receive messages with one Tag per 
socket?

Thanks!



Other related posts: