Open a Stream by either dialing (establishing an outgoing connection) or listening (accepting an incoming connection) at an address. This is a low-level interface intended for communicating with non-NNG endpoints.
stream(dial = NULL, listen = NULL, textframes = FALSE, pem = NULL)
a URL to dial, specifying the transport and address as a character string e.g. 'ipc:///tmp/anyvalue' or 'tcp://127.0.0.1:5555' (not all transports are supported).
a URL to listen at, specifying the transport and address as a character string e.g. 'ipc:///tmp/anyvalue' or 'tcp://127.0.0.1:5555' (not all transports are supported).
[default FALSE] applicable to the websocket transport only, enables sending and receiving of TEXT frames (ignored otherwise). Supplying a non-logical value will error.
(optional) applicable to secure websockets only. The path to a file containing X.509 certificate(s) in PEM format, comprising the certificate authority certificate chain (and revocation list if present). If missing or NULL, certificates are not validated.
A Stream (object of class 'nanoStream' and 'nano').
A Stream is used for raw byte stream connections. Byte streams are reliable in that data will not be delivered out of order, or with portions missing.
Can be used to dial a (secure) websocket address starting 'ws://' or 'wss://'. It is often the case that 'textframes' needs to be set to TRUE.
Specify only one of 'dial' or 'listen'. If both are specified, 'listen' will be ignored.
# will succeed only if there is an open connection at the address: s <- tryCatch(stream(dial = "tcp://127.0.0.1:5555"), error = identity) s #> <simpleError in stream(dial = "tcp://127.0.0.1:5555"): 6 | Connection refused>