[zeromq-dev] Multiplexing a TCP endpoint

Tom Quarendon tom.quarendon at teamwpc.co.uk
Wed Feb 10 20:11:46 CET 2016


This is what "resources" in ZMTP 3.1 were designed for. No implementation yet though (see other discussion on his list) :-)

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. 

Hope that helps.

-----Original Message-----
From: zeromq-dev-bounces at lists.zeromq.org [mailto:zeromq-dev-bounces at lists.zeromq.org] On Behalf Of Alex Bligh
Sent: 10 February 2016 17:24
To: zeromq-dev at lists.zeromq.org
Cc: Alex Bligh <alex at alex.org.uk>
Subject: [zeromq-dev] Multiplexing a TCP endpoint

I am investigating building a zeromq-based application which runs over TCP. It will run many separate services over zeromq, mostly REP/REQ (via proxies), but also PUB/SUB.

The normal way to do this as far as I can tell is to use one TCP port per service. I want to avoid doing this, as the services can be dynamically created and deleted and I don't want to be bothered with different firewall rules, port management etc.

For inproc communication that's fine, as I can specify a unique name. However, the TCP endpoint does not have this. Only one socket can bind to a tcp port.

What I'd really like to do is simply to multiplex (by service name) multiple services (i.e. multiple sockets) onto the same TCP port. They would then pass like shadows in the night. I would like this to transparently work with encryption too.

I think this would be no harder than adding an additional frame (the service name) on send, and stripping it on receive. However, I can't immediately see how to do this using standard Router / Dealer code (partly because I'd have to somehow route the messages to the correct endpoints that had 'connected'), though I may be missing something. In many ways it would seem to be easier to modify the endpoint protocol.

Am I missing something? Am I approaching this the right way?

-- 
Alex Bligh




_______________________________________________
zeromq-dev mailing list
zeromq-dev at lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev



More information about the zeromq-dev mailing list