Skip to content

Instantly share code, notes, and snippets.

@somdoron
Created August 14, 2015 12:55
Show Gist options
  • Save somdoron/542b74922f652d229566 to your computer and use it in GitHub Desktop.
Save somdoron/542b74922f652d229566 to your computer and use it in GitHub Desktop.
Using Client Server socket types with CZMQ
// Create server and client sockets and connect over inproc
zsock_t *server = zsock_new_server ("@inproc://zframe-server.test");
zsock_t *client = zsock_new_client (">inproc://zframe-server.test");
// Send message from client to server
zframe_t frame = zframe_new ("Hello", 5);
int rc = zframe_send (&frame, client, 0);
// Read message
frame = zframe_recv (server);
zframe_t *reply_frame = zframe_new("Reply", 5);
rc = zframe_send_reply(&reply_frame, frame, server, 0);
zframe_destroy(&frame);
// Read reply
frame = zframe_recv (client);
zframe_destroy(&frame);
zsock_destroy (&client);
zsock_destroy (&server);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment