Skip to content

Instantly share code, notes, and snippets.

@briansorahan
Last active August 29, 2015 14:11
Show Gist options
  • Save briansorahan/f5534851865b2a39523d to your computer and use it in GitHub Desktop.
Save briansorahan/f5534851865b2a39523d to your computer and use it in GitHub Desktop.
zmq os x crash
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <zmq.h>
#define SOCKS 1000
#define ZMQ_SUCCESS 0
#define ZMQ_FAILURE -1
int main() {
int i;
void *ctx = zmq_ctx_new();
void *sockets[SOCKS];
int fds[SOCKS];
size_t fd_size = sizeof(int);
assert(ctx);
printf("ZMQ_MAX_SOCKETS=%d\n", zmq_ctx_get(ctx, ZMQ_MAX_SOCKETS));
printf("----------------------------------------\n");
for (i = 0; i < SOCKS; i++) {
printf("%d,", i);
sockets[i] = zmq_socket(ctx, ZMQ_DEALER);
if (NULL == sockets[i]) {
printf("\n");
printf("zmq_errno() == %d\n", zmq_errno());
printf("%s\n", zmq_strerror(zmq_errno()));
return 1;
}
/* assert(ZMQ_SUCCESS == zmq_getsockopt(sockets[i], ZMQ_FD, &fds[i], &fd_size)); */
if (zmq_getsockopt(sockets[i], ZMQ_FD, &fds[i], &fd_size)) {
printf("%s\n", zmq_strerror(zmq_errno()));
return 1;
}
}
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment