Created
August 23, 2012 05:38
-
-
Save kjdev/3433068 to your computer and use it in GitHub Desktop.
ZeroMQ and Crossroads I/O
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Crossroad I/O Client */ | |
#include "xs/xs.h" | |
#include <string.h> | |
int main(int argc, char **argv) | |
{ | |
void *ctx = xs_init(); | |
void *backend = xs_socket(ctx, XS_DEALER); | |
//xs_bind (backend, "ipc://backend"); | |
xs_bind (backend, "tcp://127.0.0.1:5570"); | |
xs_msg_t msg; | |
xs_msg_init_size (&msg, 6); | |
memset (xs_msg_data (&msg), 'A', 6); | |
xs_sendmsg (backend, &msg, 0); | |
xs_close(backend); | |
xs_term(ctx); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Crossroad I/O Server */ | |
#include "xs/xs.h" | |
#include <stdio.h> | |
int main(int argc, char **argv) | |
{ | |
void *ctx = xs_init(); | |
void *worker = xs_socket(ctx, XS_DEALER); | |
//xs_connect (worker, "ipc://backend"); | |
xs_connect (worker, "tcp://127.0.0.1:5570"); | |
while (1) { | |
xs_msg_t msg; | |
xs_msg_init (&msg); | |
xs_recvmsg(worker, &msg, 0); | |
fprintf(stderr, "recv\n"); | |
} | |
xs_close(worker); | |
xs_term(ctx); | |
return 0; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ZeroMQ Client */ | |
#include "zmq.h" | |
#include <string.h> | |
int main(int argc, char **argv) | |
{ | |
void *ctx = zmq_init(1); | |
void *backend = zmq_socket(ctx, ZMQ_DEALER); | |
//zmq_bind(backend, "ipc://backend"); | |
zmq_bind(backend, "tcp://127.0.0.1:5570"); | |
zmq_msg_t msg; | |
zmq_msg_init_size (&msg, 6); | |
memset (zmq_msg_data (&msg), 'A', 6); | |
zmq_send (backend, &msg, 0); | |
zmq_close(backend); | |
zmq_term(ctx); | |
return 0; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ZeroMQ Server */ | |
#include "zmq.h" | |
#include <stdio.h> | |
int main(int argc, char **argv) | |
{ | |
void *ctx = zmq_init(1); | |
void *worker = zmq_socket(ctx, ZMQ_DEALER); | |
//zmq_connect(worker, "ipc://backend"); | |
zmq_connect(worker, "tcp://127.0.0.1:5570"); | |
while (1) { | |
zmq_msg_t msg; | |
zmq_msg_init (&msg); | |
zmq_recv(worker, &msg, 0); | |
fprintf(stderr, "recv\n"); | |
} | |
zmq_close(worker); | |
zmq_term(ctx); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment