Skip to content

Instantly share code, notes, and snippets.

@calid
Last active August 29, 2015 14:17
Show Gist options
  • Save calid/9d35cfd77fc6cb043d21 to your computer and use it in GitHub Desktop.
Save calid/9d35cfd77fc6cb043d21 to your computer and use it in GitHub Desktop.
zmq_unbind fail
#include <zmq.h>
#include <assert.h>
#include <stdio.h>
int main(void)
{
int rc;
void *context = zmq_ctx_new();
void *socket = zmq_socket(context, ZMQ_SUB);
assert(socket);
int major, minor, patch;
zmq_version(&major, &minor, &patch);
printf("ZMQ VERSION=%d.%d.%d\n", major, minor, patch);
rc = zmq_bind(socket, "tcp://*:5555");
assert(rc == 0);
char endpoint[256];
size_t endpoint_len = sizeof(endpoint);
rc = zmq_getsockopt(socket, ZMQ_LAST_ENDPOINT, endpoint, &endpoint_len);
assert(rc == 0);
printf("LAST ENDPOINT=%s\n", endpoint);
rc = zmq_unbind(socket, endpoint);
if ( rc == -1 ) {
perror("zmq_unbind");
return 1;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment