Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <zmq.h>
- #define ENDPOINT "ipc://@test"
- int main()
- {
- void *ctx = zmq_ctx_new();
- if (!ctx) {
- perror("Error creating context");
- return 1;
- }
- void *sock = zmq_socket(ctx, ZMQ_PUB);
- if (!sock) {
- perror("Error creating socket");
- return 1;
- }
- if (zmq_bind(sock, ENDPOINT) < 0) {
- perror("Bind error");
- return 1;
- }
- char buf[255];
- while (fgets(buf, sizeof(buf), stdin)) {
- if (zmq_send(sock, buf, strlen(buf), 0) < 0) {
- perror("Send error");
- return 1;
- }
- }
- printf("exiting...\n");
- zmq_close(sock);
- zmq_ctx_destroy(ctx);
- return 0;
- }
Add Comment
Please, Sign In to add comment