File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -244,9 +244,12 @@ impl UdpSocket {
244
244
} ) )
245
245
}
246
246
247
- /// Sends data on the socket to the given address.
247
+ /// Sends data on the socket to the remote address to which it is connected .
248
248
///
249
- /// On success, returns the number of bytes written.
249
+ /// The [`connect`] method will connect this socket to a remote address.
250
+ /// This method will fail if the socket is not connected.
251
+ ///
252
+ /// [`connect`]: #method.connect
250
253
///
251
254
/// # Examples
252
255
///
@@ -297,12 +300,11 @@ impl UdpSocket {
297
300
/// #
298
301
/// use async_std::net::UdpSocket;
299
302
///
300
- /// let socket = UdpSocket::bind("127.0.0.1:0 ").await?;
303
+ /// let socket = UdpSocket::bind("127.0.0.1:7878 ").await?;
301
304
/// socket.connect("127.0.0.1:8080").await?;
305
+ /// let bytes = socket.send(b"Hi there!").await?;
302
306
///
303
- /// let mut buf = vec![0; 1024];
304
- /// let n = socket.recv(&mut buf).await?;
305
- /// println!("Received {} bytes", n);
307
+ /// println!("Sent {} bytes", bytes);
306
308
/// #
307
309
/// # Ok(()) }) }
308
310
/// ```
You can’t perform that action at this time.
0 commit comments