[zeromq-dev] "Who said that?"

Martin Sustrik sustrik at 250bpm.com
Thu Dec 16 13:41:23 CET 2010

Hi Oliver,

> Trying to re-remember how to obtain the return address for a given ZMQ
> message, or the ZMQ representation thereof (a UUID or something). The
> message originator might be behind a NAT system, so the originating
> address could be useless (there are too many in the world).
> What I want to know is, where does the ZMQ interface I got this message
> from think it came from? So that I can distinguish messages from
> different incoming streams behind the multiplexed socket I'm talking to.
> Consider the following pseudo code:
>       msg = interface.receive()
>       user = userLookup(msg.streamIdentifier)
>       if user:
>           user.handle(msg)
>       else:
>           loginOrGTFO(msg)
> I realize I could just slap some kind of GUID into the payload, but in
> these particular message streams, bits are at a premium.
> I recognize that the sender address/port in an IP packet should never be
> trusted any more than the words "PRIORITY MAIL" or "YOU'VE WON
> $10,000,000!" on a physical envelope, however in my particular use case
> - and for similar reasons - it makes an excellent starting point.

There's no API to get sender's address. The reason is that in multi-hop 
scenarios is not even clear, who's the sender: The original sender or 
the device at the last hop?

However, with XREQ/XREP sockets the identites of individual hops are 
aggregated in the request (as initial message parts). Check the guide 
for details.


More information about the zeromq-dev mailing list