net: add set_nonblocking to doc (#3100)

This commit is contained in:
Alice Ryhl
2020-11-06 17:01:22 +01:00
committed by GitHub
parent 47658a6da5
commit f51ddc5958
4 changed files with 4 additions and 0 deletions
+1
View File
@@ -218,6 +218,7 @@ impl TcpListener {
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn Error>> {
/// let std_listener = std::net::TcpListener::bind("127.0.0.1:0")?;
/// std_listener.set_nonblocking(true)?;
/// let listener = TcpListener::from_std(std_listener)?;
/// Ok(())
/// }
+1
View File
@@ -159,6 +159,7 @@ impl TcpStream {
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn Error>> {
/// let std_stream = std::net::TcpStream::connect("127.0.0.1:34254")?;
/// std_stream.set_nonblocking(true)?;
/// let stream = TcpStream::from_std(std_stream)?;
/// Ok(())
/// }
+1
View File
@@ -187,6 +187,7 @@ impl UdpSocket {
/// # async fn main() -> io::Result<()> {
/// let addr = "0.0.0.0:8080".parse::<SocketAddr>().unwrap();
/// let std_sock = std::net::UdpSocket::bind(addr)?;
/// std_sock.set_nonblocking(true)?;
/// let sock = UdpSocket::from_std(std_sock)?;
/// // use `sock`
/// # Ok(())
+1
View File
@@ -179,6 +179,7 @@ impl UnixDatagram {
/// // Bind the socket to a filesystem path
/// let socket_path = tmp.path().join("socket");
/// let std_socket = StdUDS::bind(&socket_path)?;
/// std_socket.set_nonblocking(true)?;
/// let tokio_socket = UnixDatagram::from_std(std_socket)?;
///
/// # Ok(())