Message Function
From pbdZMQ v0.2-1
by Wei-Chen Chen
Message Functions
Message functions
- Keywords
- programming
Usage
zmq.msg.send(rmsg, socket, flags = .pbd_env$ZMQ.SR$BLOCK, serialize = TRUE)zmq.msg.recv(socket, flags = .pbd_env$ZMQ.SR$BLOCK, unserialize = TRUE)
Arguments
- rmsg
- an R message
- socket
- a ZMQ socket
- flags
- a flag for method of send and receive
- serialize
- if serialize the
rmsg
- unserialize
- if unserialize the received R message
Details
zmq.msg.send()
sends an R message.
zmq.msg.recv()
receives an R message.
Value
zmq.msg.send()
returns 0 if successful, otherwise returns -1 and setserrno
toEFAULT
.zmq.msg.recv()
returns the message if successful, otherwise returns -1 and setserrno
toEFAULT
.
References
ZeroMQ/4.1.0 API Reference:
Programming with Big Data in R Website:
See Also
Examples
### 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, .pbd_env$ZMQ.ST$REP)
zmq.bind(responder, "tcp://*:5555")
buf <- zmq.msg.recv(responder)
set.seed(1234)
ret <- rnorm(5)
print(ret)
zmq.msg.send(ret, responder)
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, .pbd_env$ZMQ.ST$REQ)
zmq.connect(requester, "tcp://localhost:5555")
zmq.msg.send(NULL, requester)
ret <- zmq.msg.recv(requester)
print(ret)
zmq.close(requester)
zmq.ctx.destroy(context)
Community examples
Looks like there are no examples yet.