mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
net: add set_nonblocking to doc (#3100)
This commit is contained in:
@@ -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(())
|
||||
/// }
|
||||
|
||||
@@ -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(())
|
||||
/// }
|
||||
|
||||
@@ -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(())
|
||||
|
||||
@@ -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(())
|
||||
|
||||
Reference in New Issue
Block a user