Send Receive Multiple Raw Buffers | R Documentation |
Send and receive functions for multiple raw buffers
zmq.send.multipart(socket, parts, serialize = TRUE)
zmq.recv.multipart(socket, unserialize = TRUE)
socket |
a ZMQ socket |
parts |
a vector of multiple buffers to be sent |
serialize , unserialize |
if serialize/unserialize the received multiple buffers |
zmq.send.multipart()
is a high level R function to send multiple
raw messages parts
at once.
zmq.recv.multipart()
is a high level R function to receive multiple
raw messages at once.
zmq.send.multipart()
returns.
zmq.recv.multipart()
returns.
Wei-Chen Chen wccsnow@gmail.com.
ZeroMQ/4.1.0 API Reference: https://libzmq.readthedocs.io/en/zeromq4-1/
Programming with Big Data in R Website: https://pbdr.org/
zmq.msg.send()
, zmq.msg.recv()
.
## Not run:
### Using request-reply pattern.
### At the server, run next in background or the other window.
library(pbdZMQ, quietly = TRUE)
context <- zmq.ctx.new()
responder <- zmq.socket(context, ZMQ.ST()$REP)
zmq.bind(responder, "tcp://*:5555")
ret <- zmq.recv.multipart(responder, unserialize = TRUE)
parts <- as.list(rep("World", 5))
zmq.send.multipart(responder, parts)
for(i in 1:5) cat(ret[[i]])
zmq.close(responder)
zmq.ctx.destroy(context)
### At a client, run next in foreground.
library(pbdZMQ, quietly = TRUE)
context <- zmq.ctx.new()
requester <- zmq.socket(context, ZMQ.ST()$REQ)
zmq.connect(requester, "tcp://localhost:5555")
parts <- lapply(1:5, function(i.req){ paste("Sending Hello ", i.req, "\n") })
zmq.send.multipart(requester, parts)
ret <- zmq.recv.multipart(requester, unserialize = TRUE)
print(ret)
zmq.close(requester)
zmq.ctx.destroy(context)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.