Created
July 19, 2019 05:38
-
-
Save gmalysa/67da5320692983f927078b7250a0fab6 to your computer and use it in GitHub Desktop.
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
#include <zmq.h> | |
int main(void) { | |
void *context = zmq_ctx_new(); | |
void *sock = zmq_socket(context, ZMQ_REQ); | |
zmq_connect(sock, "tcp://localhost:5999"); | |
while (1) { | |
char response[10]; | |
zmq_send(sock, "hi", 2, 0); | |
zmq_recv(sock, response, 10, 0); | |
} | |
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
#lang racket | |
(require zeromq) | |
(define router (zmq-socket 'router #:bind "tcp://*:5999")) | |
(define dealer (zmq-socket 'dealer #:bind "inproc://test")) | |
(define (proxy-loop left right) | |
(define msg (zmq-recv* left)) | |
(zmq-send* right msg) | |
(proxy-loop left right)) | |
(thread (λ () (proxy-loop router dealer))) | |
(thread (λ () (proxy-loop dealer router))) | |
(define worker (zmq-socket 'rep #:connect "inproc://test")) | |
(define (worker-loop) | |
(define msg (zmq-recv* worker)) | |
(zmq-send* worker msg) | |
(print ".") | |
(worker-loop)) | |
(worker-loop) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment