[zeromq-dev] Failed to unbind socket (which was bind with wild-card *) with real endpoint

Pieter Hintjens ph at imatix.com
Mon Oct 27 09:43:06 CET 2014


It's a fair point. Would you like to look into the code and propose a patch?

On Sat, Oct 25, 2014 at 5:16 PM, Patryk <lysy.loren at gmail.com> wrote:
> When we bind socket with wild-card * address (e.g. "tcp://127.0.0.1:*" or
> "ipc://*"),
> and try to unbind with real endpoint then it fails with error "No such file
> or directory".
> Example code:
>
> #include <zmq.h>
> #include <stdio.h>
> #include <unistd.h>
> #include <string.h>
> #include <assert.h>
> int main (void) {
>     int rc;
>     size_t buf_size=100;
>     char buffer[buf_size];
>     void *context = zmq_ctx_new ();
>     void *socket = zmq_socket (context, ZMQ_SUB);
>     rc = zmq_bind (socket, "tcp://127.0.0.1:*");
>     assert (rc == 0);
>     rc = zmq_getsockopt (socket, ZMQ_LAST_ENDPOINT, buffer, &buf_size);
>     assert (rc == 0);
>     printf("%s\n", buffer);
>     rc = zmq_unbind (socket, buffer);
>     if (rc == -1)
>         printf ("ERROR: %s\n", strerror (errno));
> }
>
> The output of executing above is:
>
> tcp://127.0.0.1:39969
> ERROR: No such file or directory
>
> When we try to unbind with endpoint "tcp://127.0.0.1:*" it unbinds clearly.
> This behaviour is ok, when we have one binding per socket.
> BUT when we bind socket to several endpoints with wild-card we have no
> control over
> exact unbinding our endpoints. I think we REALLY SHOULD be able to unbind
> socket by real endpoint
> returned via getsockopt(ZMQ_LAST_ENDPOINT).
>
> The same behaviour with ipc transport ("ipc://*").
>
> Tested on zmq 4.0.4 on Debian Jessie.
>
>
> --
> Loren
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



More information about the zeromq-dev mailing list