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