inst/examples/reqrep/client.r

if (!interactive())
  stop("Please run the client interactively; you can do so by executing 'source(\"client.r\")' from an interactive R session.")

library(pbdZMQ)
ctxt <- zmq.ctx.new()
socket <- zmq.socket(ctxt, ZMQ.ST()$REQ)
zmq.connect(socket, "tcp://localhost:55555")

sendrecv <- function(socket, data)
{
  zmq.msg.send(data, socket)
  zmq.msg.recv(socket)
}

cat("Send commands to the server using sendrecv().\nFor example, 'sendrecv(socket, \"1+1\")'.\nSend 'sendrecv(socket, \"EXIT\")' to shut down the server.\n\n")

Try the pbdZMQ package in your browser

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

pbdZMQ documentation built on Sept. 8, 2023, 6:06 p.m.