Debian Codegraph @

man/context.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/context.R
3 \name{context}
4 \alias{context}
5 \title{Open Context}
6 \usage{
7 context(socket)
8 }
9 \arguments{
10 \item{socket}{a Socket.}
11 }
12 \value{
13 A Context (object of class 'nanoContext' and 'nano').
14 }
15 \description{
16 Open a new Context to be used with a Socket. The purpose of a Context is to
17 permit applications to share a single socket, with its underlying dialers and
18 listeners, while still benefiting from separate state tracking.
19 }
20 \details{
21 Contexts allow the independent and concurrent use of stateful operations
22 using the same socket. For example, two different contexts created on a rep
23 socket can each receive requests, and send replies to them, without any
24 regard to or interference with each other.
25
26 Only the following protocols support creation of contexts: req, rep, sub
27 (in a pub/sub pattern), surveyor, respondent.
28
29 To send and receive over a context use \code{\link[=send]{send()}} and \code{\link[=recv]{recv()}} or their async
30 counterparts \code{\link[=send_aio]{send_aio()}} and \code{\link[=recv_aio]{recv_aio()}}.
31
32 For nano objects, use the \verb{$context_open()} method, which will attach a new
33 context at \verb{$context}. See \code{\link[=nano]{nano()}}.
34 }
35 \examples{
36 s <- socket("req", listen = "inproc://nanonext")
37 ctx <- context(s)
38 ctx
39 close(ctx)
40 close(s)
41
42 n <- nano("req", listen = "inproc://nanonext")
43 n$context_open()
44 n$context
45 n$context_open()
46 n$context
47 n$context_close()
48 n$close()
49
50 }
51 \seealso{
52 \code{\link[=request]{request()}} and \code{\link[=reply]{reply()}} for use with contexts.
53 }