Skip to content

Instantly share code, notes, and snippets.

@hintjens
Created February 16, 2011 20:15
Show Gist options
  • Save hintjens/830088 to your computer and use it in GitHub Desktop.
Save hintjens/830088 to your computer and use it in GitHub Desktop.
Crash 0MQ
//
// Crash mailbox... inspired by Chuck Remes
//
#include <zmq.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
// Specify any two legally combineable socket types
#define SERVER ZMQ_PAIR
#define CLIENT ZMQ_PAIR
int main (int argc, char *argv[])
{
void *context = zmq_init (1);
void *server = zmq_socket (context, SERVER);
zmq_bind (server, "tcp://*:5055");
void *client1 = zmq_socket (context, CLIENT);
zmq_setsockopt (client1, ZMQ_IDENTITY, "DIE", 3);
zmq_connect (client1, "tcp://localhost:5055");
void *client2 = zmq_socket (context, CLIENT);
zmq_setsockopt (client2, ZMQ_IDENTITY, "DIE", 3);
zmq_connect (client2, "tcp://localhost:5055");
// 0MQ crashes here
sleep (1);
zmq_close (client1);
zmq_close (client2);
zmq_close (server);
zmq_term (context);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment