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

Patryk lysy.loren at gmail.com
Sat Oct 25 17:16:01 CEST 2014

When we bind socket with wild-card * address (e.g. "tcp://*" or
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://*");
    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:


ERROR: No such file or directory

When we try to unbind with endpoint "tcp://*" 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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20141025/a36d473a/attachment.htm>

More information about the zeromq-dev mailing list