Learn R Programming

nanonext (version 0.2.0)

send: Send

Description

Send data over a Socket.

Usage

send(socket, data, mode = c("serial", "raw"), block = FALSE, echo = TRUE)

Arguments

socket

a Socket.

data

an R object (if mode = 'raw', an R vector).

mode

[default 'serial'] whether data will be sent serialized or as a raw vector. Use 'serial' for sending and receiving within R to ensure perfect reproducibility. Use 'raw' for sending vectors of any type (will be converted to a raw byte vector for sending) - essential when interfacing with external applications.

block

[default FALSE] logical flag whether to block until successful or return immediately even if unsuccessful (e.g. no connection available).

echo

[default TRUE] logical flag whether to return the raw vector of sent data. Set to FALSE for performance-critical applications where invisble NULL will be returned instead.

Value

Raw vector of sent data, or zero (invisibly) if 'echo' is set to FALSE.

Examples

Run this code
# NOT RUN {
pub <- socket("pub", dial = "inproc://nanonext")

send(pub, data.frame(a = 1, b = 2))
send(pub, c(10.1, 20.2, 30.3), mode = "raw")

close(pub)

# }

Run the code above in your browser using DataLab