Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (21 sloc) 684 Bytes
;; synchronized publisher : send 1M messages to subscribers to :5561 after
;; all expected subscribers tell :5562 they are ready
(use zmq)
(define +subscribers-expected+ 20)
(define sync (make-socket 'rep))
(define pub (make-socket 'pub))
(bind-socket pub "tcp://*:5561")
(bind-socket sync "tcp://*:5562")
(do ((i 0 (+ i 1)))
((>= i +subscribers-expected+))
(receive-message sync)
(print "Synced subscriber " (+ i 1))
(send-message sync ""))
(do ((i 0 (+ i 1)))
((>= i 1000000))
(send-message pub "Rhubarb"))
(send-message pub "END")
;; If we don't tidy up we get client hangs.
(close-socket pub)
(close-socket sync)
(terminate-context (zmq-default-context))
Something went wrong with that request. Please try again.