If x is missing, blocking pops the oldest Message object from the communication queue as created by start. An open connection with the sender may be maintained if keep_conn is set to TRUE. Alternatively, if an existing connection as given by a FD object is passed as x, then the file descriptor is listened on. S3 method dispatching on x.

receive(x, keep_conn = FALSE, simplify = TRUE, ...)
receive.FD(x, keep_conn=FALSE, simplify=TRUE,...)

Arguments

x

Optional file descriptor or other S3 class. Reads from background communication queue if missing.

keep_conn

Logical whether to maintain or close the connection.

simplify

Simplify Message output.

...

Further arguments to methods.

Value

If from the message queue, a Message, composed of components:

header
payload
location
fd

Arbitrary otherwise.

See also

Examples

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--  or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (x, keep_conn = FALSE, simplify = TRUE, ...) 
{
    stopifnot(ORCV_GLOBAL$STARTED)
    if (missing(x)) {
        next_msg <- .Call(C_next_message)
        if (is.null(next_msg)) 
            stop("receive error")
        msg <- as.Message(next_msg)
        cat(sprintf("Opening message with header \"%s\"\n", header(msg)))
        if (!keep_conn) {
            close(msg)
            fd(msg) <- as.FD(-1L)
        }
        if (!simplify) 
            msg <- list(msg)
        invisible(msg)
    }
    else UseMethod("receive", x)
  }
#> function (x, keep_conn = FALSE, simplify = TRUE, ...) 
#> {
#>     stopifnot(ORCV_GLOBAL$STARTED)
#>     if (missing(x)) {
#>         next_msg <- .Call(C_next_message)
#>         if (is.null(next_msg)) 
#>             stop("receive error")
#>         msg <- as.Message(next_msg)
#>         cat(sprintf("Opening message with header \"%s\"\n", header(msg)))
#>         if (!keep_conn) {
#>             close(msg)
#>             fd(msg) <- as.FD(-1L)
#>         }
#>         if (!simplify) 
#>             msg <- list(msg)
#>         invisible(msg)
#>     }
#>     else UseMethod("receive", x)
#>   }
#> <environment: 0x55fcee867aa8>