Function async_native_tls::connect
source · pub async fn connect<S>(host: impl Into<Host>, stream: S) -> Result<TlsStream<S>>where
S: AsyncRead + AsyncWrite + Unpin,
Expand description
Connect a client to a remote server.
Examples
use async_std::prelude::*;
use async_std::net::TcpStream;
let stream = TcpStream::connect("google.com:443").await?;
let mut stream = async_native_tls::connect("google.com", stream).await?;
stream.write_all(b"GET / HTTP/1.0\r\n\r\n").await?;
let mut res = Vec::new();
stream.read_to_end(&mut res).await?;
println!("{}", String::from_utf8_lossy(&res));