[zeromq-dev] subports

Martin Sustrik sustrik at 250bpm.com
Wed Jul 27 09:48:58 CEST 2011

Hi all,

The subport feature (multiplexing several connections on top of the same 
TCP port) have been asked for a long time.

I've committed the initial version of the functionality to "vtcp" branch 
in libzmq repo. It's still a bit creaky, but it should work at least on 
POSIX-compliant systems.

How it works

There's "vtcp" project that deals with TCP port multiplexing. Note that 
it is not 0MQ-specific. It can multiplex connections from any applications.

Technically, there's "vtcpd" deamon that listens on a specific TCP port 
and dispatches new connections to the applications on the local box 
based on the subport number.

Applications (including 0MQ) use libvtcp library to bind/connect to vtcp 

In wire-protocol terms, vtcp requires that 32-bit network-byte-ordered 
integer (subport number) is sent by the connecting side immediately 
after creating the TCP connection.


1. Get vtcp project here:


2. Build and isntall it:

    sudo make install

3. Get 0MQ from libzmq repo, vtcp branch
4. Build it with --with-vtcp option:

    ./configure --with-vtcp
    sudo make install

5. Run the vtcp deamon on the port you want to multiplex:

    vtcpd 5555

6. Test it using 0MQ perf tests:

    local_lat vtcp://*:5555.123 1 1

    remote_lat vtcp:// 1 1

Please note that vtcp only allows binding to *all* the network 
interfaces (*). Trying to bind to a specific interface will produce error.


Addresses like "vtcp://" are annoyingly long. Would it 
make sense to use a well-know fixed port (such as 5555) for 
multiplexing? That way the address could be shortned to 

Any feedback is welcome.


More information about the zeromq-dev mailing list