File: a2_message.Rd

package info (click to toggle)
r-cran-pbdzmq 0.3.13%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 856 kB
  • sloc: ansic: 737; sh: 93; pascal: 30; cpp: 6; makefile: 4
file content (94 lines) | stat: -rw-r--r-- 2,193 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/R_zmq_message.r
\name{Message Function}
\alias{Message Function}
\alias{zmq.msg.send}
\alias{zmq.msg.recv}
\title{Message Functions}
\usage{
zmq.msg.send(
  rmsg,
  socket,
  flags = ZMQ.SR()$BLOCK,
  serialize = TRUE,
  serialversion = NULL
)

zmq.msg.recv(socket, flags = ZMQ.SR()$BLOCK, unserialize = TRUE)
}
\arguments{
\item{rmsg}{an R message}

\item{socket}{a ZMQ socket}

\item{flags}{a flag for method of send and receive}

\item{serialize}{if serialize the \code{rmsg}}

\item{serialversion}{NULL or numeric; the workspace format version to use when serializing.
NULL specifies the current default version. The only other supported
values are 2 and 3}

\item{unserialize}{if unserialize the received R message}
}
\value{
\code{zmq.msg.send()} returns 0 if successful, otherwise returns -1
and sets \code{errno} to \code{EFAULT}.

\code{zmq.msg.recv()} returns the message if successful, otherwise returns
-1 and sets \code{errno} to \code{EFAULT}.
}
\description{
Message functions
}
\details{
\code{zmq.msg.send()} sends an R message.

\code{zmq.msg.recv()} receives an R message.
}
\examples{
\dontrun{
### 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")
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, 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)
}

}
\references{
ZeroMQ/4.1.0 API Reference:
\url{https://libzmq.readthedocs.io/en/zeromq4-1/}

Programming with Big Data in R Website: \url{https://pbdr.org/}
}
\seealso{
\code{\link{zmq.send}()}, \code{\link{zmq.recv}()}.
}
\author{
Wei-Chen Chen \email{wccsnow@gmail.com}.
}
\keyword{programming}