# 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
if (FALSE) { # interactive()
# Run in interactive sessions only as connection is not always available:
s <- tryCatch(
stream(dial = "wss://echo.websocket.events/", textframes = TRUE),
error = identity
)
s
if (is_nano(s)) recv(s)
if (is_nano(s)) send(s, "hello")
if (is_nano(s)) recv(s)
if (is_nano(s)) close(s)
}
Run the code above in your browser using DataLab