@@ -244,9 +244,12 @@ impl UdpSocket {
244244 } ) )
245245 }
246246
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 .
248248 ///
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
250253 ///
251254 /// # Examples
252255 ///
@@ -255,18 +258,11 @@ impl UdpSocket {
255258 /// #
256259 /// use async_std::net::UdpSocket;
257260 ///
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?;
266264 ///
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);
270266 /// #
271267 /// # Ok(()) }) }
272268 /// ```
0 commit comments