DSD_ReadSocket: A DSD That Reads from a Server Port

View source: R/DSD_ReadSocket.R

DSD_ReadSocketR Documentation

A DSD That Reads from a Server Port

Description

Creates a DSD_ReadStream that reads from a port.

Usage

DSD_ReadSocket(host = "localhost", port, retry_args = NULL, ...)

Arguments

host

hostname.

port

host port.

retry_args

a list with arguments for retry().

...

further arguments are passed on to stream::DSD_ReadStream().

Value

A stream::DSD object.

See Also

Other Socket: publish_DSD_via_Socket()

Other dsd: DSD_ReadWebService(), publish_DSD_via_Socket(), publish_DSD_via_WebService()

Examples

# 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

# create a DSD that connects to the socket. Note that we need to 
# specify the column names of the stream
dsd <- DSD_ReadSocket(port = port, col.names = c("x", "y", "z", ".class"))
dsd

get_points(dsd, n = 10)

plot(dsd)

close_stream(dsd)

# end the DSD process. Note: that closing the connection above
# may already kill the process.
if (rp1$is_alive()) rp1$kill()
rp1

streamConnect documentation built on June 22, 2024, 9:55 a.m.