Learn R Programming

nanonext (version 0.2.0)

send_aio: Send Async

Description

Send data asynchronously over a Socket or Context.

Usage

send_aio(socket, data, mode = c("serial", "raw"), timeout)

Arguments

socket

a Socket or Context.

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.

timeout

in ms. If unspecified, a socket-specific default timeout will be used.

Value

A send Aio (object of class 'sendAio').

Details

Async send is always non-blocking and returns immediately.

To wait for and check the result of the send operation, use call_aio on the returned 'sendAio' object.

Alternatively, to stop the async operation, use stop_aio.

Examples

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

aio <- send_aio(pub, data.frame(a = 1, b = 2), timeout = 100)
aio
call_aio(aio)$result

aio <- send_aio(pub, "example message", mode = "raw", timeout = 100)
call_aio(aio)$result

close(pub)

# }

Run the code above in your browser using DataLab