[zeromq-dev] binding to a wildcard tcp port

Stephen Lord Steve.Lord at quantum.com
Fri Oct 26 13:22:21 CEST 2012

This is more a comment on the documentation than anything else.
All the examples in the guide that I have looked at specify an explicit
port when using tcp. For example:

   ret = zmq_bind(socket, "tcp://*:5555");

What I had to work out for myself by reading source code was that
this works:

    ret = zmq_bind(sock, "tcp://*:*");
    ret = zmq_getsockopt(sock, ZMQ_LAST_ENDPOINT, endpoint, &optlen);
    if (ret == 0) {
        printf("Bound at %s\n", endpoint);

Some would say "Well that is obvious", but it would be nice if the actual
accepted syntax for the different protocols was completely specified
somewhere in the documentation. None of the examples use this socket
option call and it has no mention outside the man page for getsockopt,
there also seems to be no way to collect all the existing bindings on a
socket rather than just the last one.

Another observation here is that the returned binding in this example is
less than useful:

    Bound at tcp://

In order to connect anything to this, I would have to dismantle it and 
replace the with a host name or iP address. Looks like there 
is code in the bowels of the library to split these apart, but the library
API does not have any tools for manipulating zeromq socket addresses.


The information contained in this transmission may be confidential. Any disclosure, copying, or further distribution of confidential information is not permitted unless such privilege is explicitly granted in writing by Quantum. Quantum reserves the right to have electronic communications, including email and attachments, sent across its networks filtered through anti virus and spam software programs and retain such messages in order to comply with applicable data security and retention requirements. Quantum is not responsible for the proper and complete transmission of the substance of this communication or for any delay in its receipt.

More information about the zeromq-dev mailing list