This repository was archived by the owner on Feb 14, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Original file line number Diff line number Diff line change 219219 (persistent! new-acc)))))
220220
221221(defn send-all
222- " Send all data parts to the socket.
223- coll is a seq containing byte arrays ."
222+ " Send all data parts to the socket. coll is a seq containing byte arrays.
223+ Does nothing if coll is empty ."
224224 [^ZMQ$Socket socket coll]
225- (loop [i 0 ]
226- (let [frame (nth coll i)
227- flags (if (= i (- (count coll) 1 ))
228- 0
229- send-more)]
230- (send socket frame flags)
231- (when (< (+ i 1 ) (count coll)) (recur (+ i 1 ))))))
225+ (loop [[x & xs] coll]
226+ (when x
227+ (if xs
228+ (do (send socket x send-more)
229+ (recur xs))
230+ (send socket x)))))
232231
233232(defn ^ZMQ$Socket set-linger
234233 " The linger option shall set the linger period for the specified socket. The
Original file line number Diff line number Diff line change 4242 (zmq/send-str router " ack" )
4343 (let [actual (zmq/receive-str dealer)]
4444 (is (= " ack" actual))))))
45+
46+ (deftest receive-all-send-all-test
47+ (let [addr " inproc://rxtx-all-test" ]
48+ (with-open [req (doto (zmq/socket context :req )
49+ (zmq/bind addr))
50+ rep (doto (zmq/socket context :rep )
51+ (zmq/connect addr))]
52+ (zmq/send-all req [(.getBytes " hello" ) (.getBytes " world" )])
53+ (let [msg (zmq/receive-all rep)]
54+ (is (= (vec (first msg)) (vec (.getBytes " hello" ))))
55+ (is (= (vec (second msg)) (vec (.getBytes " world" ))))
56+ )
57+ (zmq/send-all rep [(byte-array[] )])
58+ (let [msg (zmq/receive-all req)]
59+ (is (= (vec (first msg)) []))))))
You can’t perform that action at this time.
0 commit comments