From a4f6806605d86fcd9056beb8bfd462a4d9377f7d Mon Sep 17 00:00:00 2001 From: noah Date: Mon, 13 Jan 2020 17:47:51 -0600 Subject: [PATCH 1/3] Fixes https://github.com/async-rs/async-std/issues/652 --- src/net/udp/mod.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/net/udp/mod.rs b/src/net/udp/mod.rs index 1b6d0d74..4ff35631 100644 --- a/src/net/udp/mod.rs +++ b/src/net/udp/mod.rs @@ -244,9 +244,12 @@ impl UdpSocket { })) } - /// Sends data on the socket to the given address. + /// Sends data on the socket to the remote address to which it is connected. /// - /// On success, returns the number of bytes written. + /// The [`connect`] method will connect this socket to a remote address. + /// This method will fail if the socket is not connected. + /// + /// [`connect`]: #method.connect /// /// # Examples /// @@ -297,12 +300,11 @@ impl UdpSocket { /// # /// use async_std::net::UdpSocket; /// - /// let socket = UdpSocket::bind("127.0.0.1:0").await?; + /// let socket = UdpSocket::bind("127.0.0.1:7878").await?; /// socket.connect("127.0.0.1:8080").await?; + /// let bytes = socket.send(b"Hi there!").await?; /// - /// let mut buf = vec![0; 1024]; - /// let n = socket.recv(&mut buf).await?; - /// println!("Received {} bytes", n); + /// println!("Sent {} bytes", bytes); /// # /// # Ok(()) }) } /// ``` From 76993dd7557ca0c0c11f73b5d4e10cc91abd33de Mon Sep 17 00:00:00 2001 From: noah Date: Tue, 14 Jan 2020 10:55:10 -0600 Subject: [PATCH 2/3] Revert "Fixes https://github.com/async-rs/async-std/issues/652" This reverts commit a4f68066 --- src/net/udp/mod.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/net/udp/mod.rs b/src/net/udp/mod.rs index 4ff35631..1b6d0d74 100644 --- a/src/net/udp/mod.rs +++ b/src/net/udp/mod.rs @@ -244,12 +244,9 @@ impl UdpSocket { })) } - /// Sends data on the socket to the remote address to which it is connected. - /// - /// The [`connect`] method will connect this socket to a remote address. - /// This method will fail if the socket is not connected. + /// Sends data on the socket to the given address. /// - /// [`connect`]: #method.connect + /// On success, returns the number of bytes written. /// /// # Examples /// @@ -300,11 +297,12 @@ impl UdpSocket { /// # /// use async_std::net::UdpSocket; /// - /// let socket = UdpSocket::bind("127.0.0.1:7878").await?; + /// let socket = UdpSocket::bind("127.0.0.1:0").await?; /// socket.connect("127.0.0.1:8080").await?; - /// let bytes = socket.send(b"Hi there!").await?; /// - /// println!("Sent {} bytes", bytes); + /// let mut buf = vec![0; 1024]; + /// let n = socket.recv(&mut buf).await?; + /// println!("Received {} bytes", n); /// # /// # Ok(()) }) } /// ``` From 0a528647649971453aa5a724023a2cba84638418 Mon Sep 17 00:00:00 2001 From: noah Date: Tue, 14 Jan 2020 10:59:17 -0600 Subject: [PATCH 3/3] Revert "Fixes https://github.com/async-rs/async-std/issues/652" This reverts commit a4f68066 --- src/net/udp/mod.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/net/udp/mod.rs b/src/net/udp/mod.rs index 1b6d0d74..e3bd7146 100644 --- a/src/net/udp/mod.rs +++ b/src/net/udp/mod.rs @@ -244,9 +244,12 @@ impl UdpSocket { })) } - /// Sends data on the socket to the given address. + /// Sends data on the socket to the remote address to which it is connected. /// - /// On success, returns the number of bytes written. + /// The [`connect`] method will connect this socket to a remote address. + /// This method will fail if the socket is not connected. + /// + /// [`connect`]: #method.connect /// /// # Examples /// @@ -255,18 +258,11 @@ impl UdpSocket { /// # /// use async_std::net::UdpSocket; /// - /// const THE_MERCHANT_OF_VENICE: &[u8] = b" - /// If you prick us, do we not bleed? - /// If you tickle us, do we not laugh? - /// If you poison us, do we not die? - /// And if you wrong us, shall we not revenge? - /// "; - /// - /// let socket = UdpSocket::bind("127.0.0.1:0").await?; + /// let socket = UdpSocket::bind("127.0.0.1:34254").await?; + /// socket.connect("127.0.0.1:8080").await?; + /// let bytes = socket.send(b"Hi there!").await?; /// - /// let addr = "127.0.0.1:7878"; - /// let sent = socket.send_to(THE_MERCHANT_OF_VENICE, &addr).await?; - /// println!("Sent {} bytes to {}", sent, addr); + /// println!("Sent {} bytes", bytes); /// # /// # Ok(()) }) } /// ```