# find a free port
port <- httpuv::randomPort()
port
# create a background DSD process sending data to the port
rp1 <- DSD_Gaussians(k = 3, d = 3) %>% publish_DSD_via_Socket(port = port)
rp1
# connect to the port (retry waits for the socket to establish)
con <- retry(socketConnection(port = port, open = 'r'))
dsd <- retry(DSD_ReadStream(con, col.names = c("x", "y", "z", ".class")))
get_points(dsd, n = 10)
plot(dsd)
# close connection
close_stream(dsd)
# end the DSD process. Note: that closing the connection above
# may already kill the process.
rp1$kill()
rp1
Run the code above in your browser using DataLab