Transfer Functions for Files or Directories {pbdZMQ} | R Documentation |
Transfer Functions for Files or Directories
Description
High level functions calling zmq.sendfile()
and zmq.recvfile()
to zip, transfer, and unzip small files or directories contains small files.
Usage
zmq.senddir(
port,
infiles,
verbose = FALSE,
flags = ZMQ.SR()$BLOCK,
ctx = NULL,
socket = NULL
)
zmq.recvdir(
port,
endpoint,
outfile = NULL,
exdir = NULL,
verbose = FALSE,
flags = ZMQ.SR()$BLOCK,
ctx = NULL,
socket = NULL
)
Arguments
port |
A valid tcp port to be passed to |
infiles |
The name (as a string) vector of the in files to be zipped and to be sent away. |
verbose |
Logical; determines if a progress bar should be shown. |
flags |
A flag for the method used by |
ctx |
A ZMQ ctx. If |
socket |
A ZMQ socket based on |
endpoint |
A ZMQ socket endpoint to be passed to |
outfile |
The name (as a string) of the out file to be saved on the disk.
If |
exdir |
The name (as a string) of the out directory to save the unzip files
unzipped from the received |
Details
zmq.senddir()
calls zmq.senddir()
, and
zmq.recvdir()
calls zmq.recvdir()
.
Value
zmq.senddir()
and zmq.recvdir()
return
number of bytes (invisible) in the sent message if successful,
otherwise returns -1 (invisible) and sets errno
to the error
value, see ZeroMQ manual for details.
In addition, zmq.recvdir()
returns a zipped file name in a list.
Author(s)
Wei-Chen Chen
References
ZeroMQ/4.1.0 API Reference: https://libzmq.readthedocs.io/en/zeromq4-1/
Programming with Big Data in R Website: https://pbdr.org/
See Also
zmq.sendfile()
, zmq.recvfile()
.
Examples
## Not run:
### Run the sender and receiver code in separate R sessions.
### Receiver
library(pbdZMQ, quietly = TRUE)
zmq.recvdir(55555, "localhost", outfile = "./backup_2019.zip",
verbose = TRUE)
### or unzip to exdir
# zmq.recvdir(55555, "localhost", exdir = "./backup_2019", verbose = TRUE)
### Sender
library(pbdZMQ, quietly = TRUE)
zmq.senddir(55555, c("./pbdZMQ/R", "./pbdZMQ/src"), verbose = TRUE)
## End(Not run)