File: b1_sendrecvfile.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 (100 lines) | stat: -rw-r--r-- 2,851 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
95
96
97
98
99
100
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/R_zmq_transfer.r
\name{File Transfer Functions}
\alias{File Transfer Functions}
\alias{zmq.sendfile}
\alias{zmq.recvfile}
\title{File Transfer Functions}
\usage{
zmq.sendfile(
  port,
  filename,
  verbose = FALSE,
  flags = ZMQ.SR()$BLOCK,
  forcebin = FALSE,
  ctx = NULL,
  socket = NULL
)

zmq.recvfile(
  port,
  endpoint,
  filename,
  verbose = FALSE,
  flags = ZMQ.SR()$BLOCK,
  forcebin = FALSE,
  ctx = NULL,
  socket = NULL
)
}
\arguments{
\item{port}{A valid tcp port.}

\item{filename}{The name (as a string) of the in/out files. The in and out file names
can be different.}

\item{verbose}{Logical; determines if a progress bar should be shown.}

\item{flags}{A flag for the method used by \code{zmq_sendfile} and
\code{zmq_recvfile}}

\item{forcebin}{Force to read/send/recv/write in binary form. Typically for a Windows
system, text (ASCII) and binary files are processed differently.
If \code{TRUE}, "r+b" and "w+b" will be enforced in the C code.
This option is mainly for Windows.}

\item{ctx}{A ZMQ ctx. If \code{NULL} (default), the function will initial one at
the beginning and destroy it after finishing file transfer.}

\item{socket}{A ZMQ socket based on \code{ctx}.
If \code{NULL} (default), the function will create one at the beginning
and close it after finishing file transfer.}

\item{endpoint}{A ZMQ socket endpoint.}
}
\value{
\code{zmq.sendfile()} and \code{zmq.recvfile()} return
number of bytes (invisible) in the sent message if successful,
otherwise returns -1 (invisible) and sets \code{errno} to the error
value, see ZeroMQ manual for details.
}
\description{
High level functions calling \code{zmq_send()} and \code{zmq_recv()}
to transfer a file in 200 KiB chunks.
}
\details{
If no socket is passed, then by default \code{zmq.sendfile()} binds a
\code{ZMQ_PUSH} socket, and \code{zmq.recvfile()} connects to this with a
\code{ZMQ_PULL} socket. On the other hand, a PUSH/PULL, REQ/REP, or REP/REQ
socket pairing may be passed. In that case, the socket should already be
connected to the desired endpoint. Be careful not to pass the wrong socket
combination (e.g., do not do REQ/REQ), as this can put the processes in an
un-recoverable state.
}
\examples{
\dontrun{
### Run the sender and receiver code in separate R sessions.

# Receiver
library(pbdZMQ, quietly = TRUE)
zmq.recvfile(55555, "localhost", "/tmp/outfile", verbose=TRUE)

# Sender
library(pbdZMQ, quietly = TRUE)
zmq.sendfile(55555, "/tmp/infile", verbose=TRUE)
}

}
\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.msg.send}()}, \code{\link{zmq.msg.recv}()}.
}
\author{
Drew Schmidt and Christian Heckendorf
}
\keyword{programming}