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 {
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 ///
@@ -297,12 +300,11 @@ impl UdpSocket {
297300 /// #
298301 /// use async_std::net::UdpSocket;
299302 ///
300- /// let socket = UdpSocket::bind("127.0.0.1:0 ").await?;
303+ /// let socket = UdpSocket::bind("127.0.0.1:7878 ").await?;
301304 /// socket.connect("127.0.0.1:8080").await?;
305+ /// let bytes = socket.send(b"Hi there!").await?;
302306 ///
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);
306308 /// #
307309 /// # Ok(()) }) }
308310 /// ```
You can’t perform that action at this time.
0 commit comments