[zeromq-dev] Multiplexing a TCP endpoint
Alex Bligh
alex at alex.org.uk
Thu Feb 11 13:21:35 CET 2016
On 10 Feb 2016, at 19:11, Tom Quarendon <tom.quarendon at teamwpc.co.uk> wrote:
> This is what "resources" in ZMTP 3.1 were designed for. No implementation yet though (see other discussion on his list) :-)
Thanks. That is pretty much exactly what I was looking for (other than the 'no implementation yet though' bit).
I've only just subscribed to the list and my google search through the archives led only to a post in 2013 hoping this would be in zeromq 4.0. Do you have a pointer to the discussion (e.g. the thread title)?
I've read the relevant part of the ZTMP specification. In essence the 'resource' seems to be transmitted in the metadata when the connection is set up. I'm guessing to use this feature in a compatible way without implementation details, then:
1. On the 'connect' side, I'd merely need to add some metadata
2. On the 'bind' side, I'd need to run some form of multiplexer and look at the metadata property.
I can't however see an API way to set or read from the metadata dictionary before any messages are passed.
Am I therefore correct that it isn't possible to implement this without a change to zeromq itself?
> You would have to write the proxy loop yourself. So do a select on the external socket and all the internal sockets and know that when you pull a message from the external socket that you peel off the first frame after the delimiter, then use the service name it includes to pick which internal socket to pass the rest of the message to. The services then run independently on their own inproc (or even out of process on ipc or tcp) sockets. It's what I would end up doing to do the same thing.
That's pretty much what I concluded save for the fact that I had thought the service ID should probably be the innermost frame (possibly after the empty frame delimiter and with it's own zero frame delimiter) so the transport over TCP could (if necessary) be routed transparently through RTR sockets.
--
Alex Bligh
More information about the zeromq-dev
mailing list