Debian Codegraph @

man/a2_message.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/R_zmq_message.r
3 \name{Message Function}
4 \alias{Message Function}
5 \alias{zmq.msg.send}
6 \alias{zmq.msg.recv}
7 \title{Message Functions}
8 \usage{
9 zmq.msg.send(
10 rmsg,
11 socket,
12 flags = ZMQ.SR()$BLOCK,
13 serialize = TRUE,
14 serialversion = NULL
15 )
16
17 zmq.msg.recv(socket, flags = ZMQ.SR()$BLOCK, unserialize = TRUE)
18 }
19 \arguments{
20 \item{rmsg}{an R message}
21
22 \item{socket}{a ZMQ socket}
23
24 \item{flags}{a flag for method of send and receive}
25
26 \item{serialize}{if serialize the \code{rmsg}}
27
28 \item{serialversion}{NULL or numeric; the workspace format version to use when serializing.
29 NULL specifies the current default version. The only other supported
30 values are 2 and 3}
31
32 \item{unserialize}{if unserialize the received R message}
33 }
34 \value{
35 \code{zmq.msg.send()} returns 0 if successful, otherwise returns -1
36 and sets \code{errno} to \code{EFAULT}.
37
38 \code{zmq.msg.recv()} returns the message if successful, otherwise returns
39 -1 and sets \code{errno} to \code{EFAULT}.
40 }
41 \description{
42 Message functions
43 }
44 \details{
45 \code{zmq.msg.send()} sends an R message.
46
47 \code{zmq.msg.recv()} receives an R message.
48 }
49 \examples{
50 \dontrun{
51 ### Using request-reply pattern.
52
53 ### At the server, run next in background or the other window.
54 library(pbdZMQ, quietly = TRUE)
55
56 context <- zmq.ctx.new()
57 responder <- zmq.socket(context, ZMQ.ST()$REP)
58 zmq.bind(responder, "tcp://*:5555")
59 buf <- zmq.msg.recv(responder)
60 set.seed(1234)
61 ret <- rnorm(5)
62 print(ret)
63 zmq.msg.send(ret, responder)
64 zmq.close(responder)
65 zmq.ctx.destroy(context)
66
67
68 ### At a client, run next in foreground.
69 library(pbdZMQ, quietly = TRUE)
70
71 context <- zmq.ctx.new()
72 requester <- zmq.socket(context, ZMQ.ST()$REQ)
73 zmq.connect(requester, "tcp://localhost:5555")
74 zmq.msg.send(NULL, requester)
75 ret <- zmq.msg.recv(requester)
76 print(ret)
77 zmq.close(requester)
78 zmq.ctx.destroy(context)
79 }
80
81 }
82 \references{
83 ZeroMQ/4.1.0 API Reference:
84 \url{https://libzmq.readthedocs.io/en/zeromq4-1/}
85
86 Programming with Big Data in R Website: \url{https://pbdr.org/}
87 }
88 \seealso{
89 \code{\link{zmq.send}()}, \code{\link{zmq.recv}()}.
90 }
91 \author{
92 Wei-Chen Chen \email{[email protected]}.
93 }
94 \keyword{programming}