@@ -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
///
@@ -255,18 +258,11 @@ impl UdpSocket {
255
258
/// #
256
259
/// use async_std::net::UdpSocket;
257
260
///
258
- /// const THE_MERCHANT_OF_VENICE: &[u8] = b"
259
- /// If you prick us, do we not bleed?
260
- /// If you tickle us, do we not laugh?
261
- /// If you poison us, do we not die?
262
- /// And if you wrong us, shall we not revenge?
263
- /// ";
264
- ///
265
- /// let socket = UdpSocket::bind("127.0.0.1:0").await?;
261
+ /// let socket = UdpSocket::bind("127.0.0.1:34254").await?;
262
+ /// socket.connect("127.0.0.1:8080").await?;
263
+ /// let bytes = socket.send(b"Hi there!").await?;
266
264
///
267
- /// let addr = "127.0.0.1:7878";
268
- /// let sent = socket.send_to(THE_MERCHANT_OF_VENICE, &addr).await?;
269
- /// println!("Sent {} bytes to {}", sent, addr);
265
+ /// println!("Sent {} bytes", bytes);
270
266
/// #
271
267
/// # Ok(()) }) }
272
268
/// ```
0 commit comments