From 09e7416ee9588f131493e29491b46cc09a9560b5 Mon Sep 17 00:00:00 2001 From: lysyloren Date: Mon, 27 Oct 2014 14:16:36 +0100 Subject: [PATCH] Unbind socket with real endpoint when binding by wild-card * address --- doc/zmq_ipc.txt | 8 +++++++- doc/zmq_tcp.txt | 5 +++++ src/socket_base.cpp | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/doc/zmq_ipc.txt b/doc/zmq_ipc.txt index c0db4951..b8ccc143 100644 --- a/doc/zmq_ipc.txt +++ b/doc/zmq_ipc.txt @@ -35,7 +35,7 @@ operating system namespace used by the 'ipc' implementation, and must fulfill any restrictions placed by the operating system on the format and length of a 'pathname'. -When the address is `*`, _zmq_bind()_ shall generate a unique temporary +When the address is wild-card `*`, _zmq_bind()_ shall generate a unique temporary pathname. The caller should retrieve this pathname using the ZMQ_LAST_ENDPOINT socket option. See linkzmq:zmq_getsockopt[3] for details. @@ -57,6 +57,12 @@ NOTE: IPC pathnames have a maximum size that depends on the operating system. On Linux, the maximum is 113 characters including the "ipc://" prefix (107 characters for the real path name). +Unbinding wild-card address from a socket +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When wild-card `*` 'endpoint' was used in _zmq_bind()_, the caller should use +real 'endpoind' obtained from the ZMQ_LAST_ENDPOINT socket option to unbind +this 'endpoint' from a socket using _zmq_unbind()_. + Connecting a socket ~~~~~~~~~~~~~~~~~~~ When connecting a 'socket' to a peer address using _zmq_connect()_ with the diff --git a/doc/zmq_tcp.txt b/doc/zmq_tcp.txt index 4b85b534..de89c063 100644 --- a/doc/zmq_tcp.txt +++ b/doc/zmq_tcp.txt @@ -46,6 +46,11 @@ When using ephemeral ports, the caller should retrieve the actual assigned port using the ZMQ_LAST_ENDPOINT socket option. See linkzmq:zmq_getsockopt[3] for details. +Unbinding wild-card addres from a socket +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When wild-card `*` 'endpoint' was used in _zmq_bind()_, the caller should use +real 'endpoind' obtained from the ZMQ_LAST_ENDPOINT socket option to unbind +this 'endpoint' from a socket using _zmq_unbind()_. Connecting a socket ~~~~~~~~~~~~~~~~~~~ diff --git a/src/socket_base.cpp b/src/socket_base.cpp index 363d9844..433f53fe 100644 --- a/src/socket_base.cpp +++ b/src/socket_base.cpp @@ -401,7 +401,7 @@ int zmq::socket_base_t::bind (const char *addr_) // Save last endpoint URI listener->get_address (last_endpoint); - add_endpoint (addr_, (own_t *) listener, NULL); + add_endpoint (last_endpoint.c_str (), (own_t *) listener, NULL); return 0; } @@ -420,7 +420,7 @@ int zmq::socket_base_t::bind (const char *addr_) // Save last endpoint URI listener->get_address (last_endpoint); - add_endpoint (addr_, (own_t *) listener, NULL); + add_endpoint (last_endpoint.c_str (), (own_t *) listener, NULL); return 0; } #endif