Skip to main content

socket_init

Function socket_init 

Source
pub async fn socket_init(endpoint: &str) -> Result<Socket, SocketError>
Expand description

Initializes a socket connection using a single endpoint string. No transport-specific knowledge required.

Endpoint rule: If endpoint starts with ws:// or wss://, connects as remote (WebSocket). Otherwise treats as local: reads target and os from the environment first; if either is unset or invalid, returns SocketError::Detection with a message that states which variable is missing or invalid. On Windows (local), if the string does not start with \\.\pipe\, that prefix is added automatically.

Set the target and os environment variables for local connections; use a WebSocket URL for remote.