Learn R Programming

nanonext (version 0.1.0)

context: Open Context

Description

Open a new Context to be used with a Socket. The purpose of a Context is to permit applications to share a single socket, with its underlying dialers and listeners, while still benefiting from separate state tracking.

Usage

context(socket)

Arguments

socket

a Socket or nano object.

Value

A new Context (object of class 'nanoContext' and 'nano').

Details

For convenience, this function may be called on a nano object as well as a socket, in which case it is the equivalent of calling the function on the object's socket directly.

Contexts allow the independent and concurrent use of stateful operations using the same socket. For example, two different contexts created on a rep socket can each receive requests, and send replies to them, without any regard to or interference with each other.

Note: not every protocol supports creation of separate contexts.

To send and receive over a context use ctx_send or ctx_send_vec and ctx_recv or ctx_recv_vec respectively.

Examples

Run this code
# NOT RUN {
s <- socket("req", listen = "inproc://nanonext")
ctx <- context(s)
ctx
close(ctx)
close(s)

n <- nano("req", listen = "inproc://nanonext")
ctx <- context(n)
ctx
close(ctx)
n$socket_close()

# }

Run the code above in your browser using DataLab