@@ -321,6 +321,19 @@ proc receive*(s: ZSocket, flags: ZSendRecvOptions = NOFLAGS): string =
321
321
# # Return an empty string on EAGAIN
322
322
tryReceive (s, flags).msg
323
323
324
+ proc receiveAll * (s: ZSocket , flags: ZSendRecvOptions = NOFLAGS ): seq [string ] =
325
+ # # Receive all parts of a message
326
+ # #
327
+ # # If EAGAIN occurs without any data being received, it will be an empty seq
328
+ var expectMessage = true
329
+ while expectMessage:
330
+ let (msgAvailable, moreAvailable, msg) = tryReceive (s, flags)
331
+ if msgAvailable:
332
+ result .add msg
333
+ expectMessage = moreAvailable
334
+ else :
335
+ expectMessage = false
336
+
324
337
proc tryReceive * (c: ZConnection , flags: ZSendRecvOptions = NOFLAGS ): tuple [msgAvailable: bool , moreAvailable: bool , msg: string ] =
325
338
# # Receives a message from a connection.
326
339
# #
@@ -337,14 +350,8 @@ proc receiveAll*(c: ZConnection, flags: ZSendRecvOptions = NOFLAGS): seq[string]
337
350
# # Receive all parts of a message
338
351
# #
339
352
# # If EAGAIN occurs without any data being received, it will be an empty seq
340
- var expectMessage = true
341
- while expectMessage:
342
- let (msgAvailable, moreAvailable, msg) = tryReceive (c, flags)
343
- if msgAvailable:
344
- result .add msg
345
- expectMessage = moreAvailable
346
- else :
347
- expectMessage = false
353
+ receiveAll (c.socket, flags)
354
+
348
355
349
356
proc proxy * (frontend, backend: ZConnection ) =
350
357
# # The proxy connects a frontend socket to a backend socket. Data flows from frontend to backend.
0 commit comments