| device_aio | R Documentation |
Create an asynchronous device: a zero-copy forwarder that relays raw messages between two Sockets. This is the building block for brokers and proxies, such as a publisher/subscriber relay or a pair-to-pair bridge.
device_aio(s1, s2 = s1)
s1 |
a Socket, in raw mode. |
s2 |
a Socket, in raw mode, using the complementary protocol to |
A device runs on background threads and relays messages until it is stopped or
an error occurs. The returned 'sendAio' resolves only at that point: its
$result is an 'unresolved' logical NA while the device is running, and
otherwise the integer exit code (usually the error that caused it to stop,
such as a Socket being closed).
Both Sockets must be opened in raw mode (see socket()) and use complementary
protocols, that is the peer protocol of each must be the protocol of the other
(for example two 'pair' Sockets, or a 'pub' and a 'sub' Socket). The same
Socket may be supplied for both arguments to create a reflector.
To stop the device, use stop_aio(), or close either of the Sockets. To block
and wait for the device to stop, use call_aio().
A 'sendAio' (object of class 'sendAio') (invisibly).
send_aio() for the structure of the returned 'sendAio'.
s1 <- socket("pair", listen = "inproc://device1", raw = TRUE)
s2 <- socket("pair", listen = "inproc://device2", raw = TRUE)
dev <- device_aio(s1, s2)
dev$result
stop_aio(dev)
dev$result
close(s1)
close(s2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.