[zeromq-dev] Binding to TCP port 0
Robert Kern
robert.kern at gmail.com
Thu Jan 26 16:51:17 CET 2012
On 1/26/12 3:07 PM, AJ Lewis wrote:
> On Thu, Jan 26, 2012 at 03:57:37PM +0100, Martin Lucina wrote:
>> This leaves us with something like this proposal:
>>
>> zmq_bind(foo, "tcp://XXXX:*"); // "tcp://*:*" if you want
>> INADDR_ANY char endpoint [ZMQ_ENDPOINT_MAX]; zmq_getsockopt(foo,
>> ZMQ_GET_ENDPOINT, endpoint, sizeof endpoint);
>>
>> => endpoint is filled as "tcp://XXXX:12345".
>>
>> zmq_bind(foo, "ipc://*"); char endpoint [ZMQ_ENDPOINT_MAX];
>> zmq_getsockopt(foo, ZMQ_GET_ENDPOINT, endpoint, sizeof endpoint);
>>
>> => endpoint is filled as "ipc:///tmp/Xyz358hfA7".
>>
>> inproc:// semantics would be identical to ipc:// (w/o the /tmp/ prefix
>> obviously).
>>
>> The use of "*" seems fairly uncontroversial -- note that this means an
>> ipc:// endpoint cannot therefore contain "*" which is an (albeit
>> niche) backward-incompatible change.
>
> I think the "*" is fine, and it makes sense to me to extend it to all
> endpoint types. I'm a bit concerned about having the full
> ${transport}://${path/port} string passed back. That means that the app
> needs to parse that string out to get what it needs, when what it really
> wants is just the ${path/port} depending on the transport. Is there a
> reason to include more than the part of the transport string that was
> wildcarded?
The immediate use case I can think of is to make an ad hoc channel for
communicating with a particular client and communicating the new endpoint to the
client via an already established channel. While that my code (and possibly the
client) already "knows" the transport and the hostname and just needs to know
the port, what it really wants to communicate is the endpoint that the client
should connect to. If I just get the port number, then I still need to
reconstruct the whole endpoint string in order to connect to the new bound
socket. I think this is universal. Every time you bind a socket, you want
something connect to it, and that something needs the full endpoint address in
order to connect.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the zeromq-dev
mailing list