Skip to content

Instantly share code, notes, and snippets.

@somdoron
Created January 18, 2016 13:06
Show Gist options
  • Save somdoron/c9946e1a4fefd69db2c9 to your computer and use it in GitHub Desktop.
Save somdoron/c9946e1a4fefd69db2c9 to your computer and use it in GitHub Desktop.
int main (void)
{
setup_test_environment ();
int i;
for (i = 0; i < 100; i++)
{
void *ctx = zmq_ctx_new ();
assert (ctx);
zmq_msg_t msg;
int rc = zmq_msg_init (&msg);
assert (rc == 0);
void *server = zmq_socket (ctx, ZMQ_SERVER);
int value = 15;
rc = zmq_setsockopt (server, ZMQ_SNDTIMEO, &value, sizeof(int));
assert (rc == 0);
rc = zmq_bind (server, "inproc://127.0.0.1:5560");
assert (rc == 0);
void *client = zmq_socket (ctx, ZMQ_CLIENT);
rc = zmq_connect (client, "inproc://127.0.0.1:5560");
assert (rc == 0);
char data = 0;
rc = zmq_send (client, &data, 1, 0);
assert (rc == 1);
rc = zmq_msg_recv (&msg, server, 0);
assert (rc == 1);
rc = zmq_disconnect (client, "inproc://127.0.0.1:5560");
assert (rc == 0);
rc = zmq_msg_send (&msg, server, 0);
assert (rc == -1);
assert (errno == EAGAIN);
rc = zmq_close (server);
assert (rc == 0);
rc = zmq_close (client);
assert (rc == 0);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
printf ("%d\n", i);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment