[−][src]Function opentls::async_io::connect
pub async fn connect<S>(
host: impl Into<Host>,
stream: S
) -> Result<TlsStream<S>> where
S: AsyncRead + AsyncWrite + Unpin,
This is supported on crate features
io-tokio
or io-async-std
only.Connect a client to a remote server.
Examples
use async_std::prelude::*; use async_std::net::TcpStream; use opentls::async_io; let stream = TcpStream::connect("google.com:443").await?; let mut stream = async_io::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));