2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-03-28 20:16:41 +00:00
This reverts commit a4f68066
This commit is contained in:
noah 2020-01-14 10:59:17 -06:00
parent 76993dd755
commit 0a52864764

View file

@ -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 /// # Examples
/// ///
@ -255,18 +258,11 @@ impl UdpSocket {
/// # /// #
/// use async_std::net::UdpSocket; /// use async_std::net::UdpSocket;
/// ///
/// const THE_MERCHANT_OF_VENICE: &[u8] = b" /// let socket = UdpSocket::bind("127.0.0.1:34254").await?;
/// If you prick us, do we not bleed? /// socket.connect("127.0.0.1:8080").await?;
/// If you tickle us, do we not laugh? /// let bytes = socket.send(b"Hi there!").await?;
/// 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?; /// println!("Sent {} bytes", bytes);
///
/// let addr = "127.0.0.1:7878";
/// let sent = socket.send_to(THE_MERCHANT_OF_VENICE, &addr).await?;
/// println!("Sent {} bytes to {}", sent, addr);
/// # /// #
/// # Ok(()) }) } /// # Ok(()) }) }
/// ``` /// ```