demo/mpclient.r

### Multiple part client.
# SHELL> Rscript mpserver.r &
# SHELL> Rscript mpclient.r

suppressMessages(library(pbdZMQ, quietly = TRUE))

### Initial.
context <- zmq.ctx.new()
requester <- zmq.socket(context, ZMQ.ST()$REQ)
zmq.connect(requester, "tcp://localhost:5555")

### Send and receive 5 times.
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)

### Finish.
zmq.close(requester)
zmq.ctx.destroy(context)

Try the pbdZMQ package in your browser

Any scripts or data that you put into this service are public.

pbdZMQ documentation built on Sept. 11, 2024, 5:36 p.m.