Skip to main content

dial

Function dial 

Source
pub async fn dial(
    host: &str,
    port: u16,
    options: SocketOptions,
) -> Result<TcpStream>
Expand description

Open a TCP connection to host at port.

With an installed Connector, dial awaits the future of Connector::connect. The stream can still be connecting, so a refused connection can show as an error on the first read or write.

With no connector, dial resolves host as resolve does and connects to each address in turn with options. It returns the first connection that opens. On WASI, dial needs a connector, because WASI preview 1 has no connect call.

ยงErrors

Returns the error of the connector, the error of the name lookup, or the error of the last address that did not connect. With no connector on WASI, returns an error of kind io::ErrorKind::Unsupported.