[zeromq-dev] Publish / Subscribe vs Multicast
Martin Sustrik
sustrik at 250bpm.com
Tue Feb 16 15:08:26 CET 2010
Hola Gonzalo,
> [Sorry for a previous, empty message, to the list.]
Np.
> I know I am being thick here... I wrote two really small examples (34
> lines each), called sender and receiver. If I run them like this:
>
> ./sender tcp://127.0.0.1:5555 20
> ./receiver tcp://127.0.0.1:5555 20
>
> Then sender sends 20 messages to that endpoint, and receiver gets the
> same 20 messages. It works ok.
>
> Now, from what I have understood, I should be able to run things like
> this:
>
> ./sender tcp://127.0.0.1:5555 40
> ./receiver tcp://127.0.0.1:5555 20
> ./receiver tcp://127.0.0.1:5555 20
>
> And see that each receiver gets at least some of the messages. What I am
> seeing is that the first receiver that I run (i.e. the first that does a
> bind() on that endpoint) gets 20 messages, and quits. The second
> receiver never gets any messages at all.
>
> I am attaching source code for both programs, in the hopes that someone
> will tell me what I am doing wrong.
Ok. I see. You are doing it other way round. The rule of the thumb is:
The endpoint that should handle multiple connections (server) should
bind, while the one that handles only a single connection (client) connects.
So, in your case, sender should bind and receiver should connect.
Martin
More information about the zeromq-dev
mailing list