[zeromq-dev] Multiplexing a TCP endpoint

Alex Bligh alex at alex.org.uk
Wed Feb 10 18:23:41 CET 2016


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







More information about the zeromq-dev mailing list