mirror of
https://github.com/async-rs/async-std.git
synced 2025-04-26 10:16:49 +00:00
This commit is contained in:
parent
5d5064b871
commit
a4f6806605
1 changed files with 8 additions and 6 deletions
|
@ -244,9 +244,12 @@ impl UdpSocket {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends data on the socket to the given address.
|
/// Sends data on the socket to the remote address to which it is connected.
|
||||||
///
|
///
|
||||||
/// On success, returns the number of bytes written.
|
/// The [`connect`] method will connect this socket to a remote address.
|
||||||
|
/// This method will fail if the socket is not connected.
|
||||||
|
///
|
||||||
|
/// [`connect`]: #method.connect
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -297,12 +300,11 @@ impl UdpSocket {
|
||||||
/// #
|
/// #
|
||||||
/// use async_std::net::UdpSocket;
|
/// use async_std::net::UdpSocket;
|
||||||
///
|
///
|
||||||
/// let socket = UdpSocket::bind("127.0.0.1:0").await?;
|
/// let socket = UdpSocket::bind("127.0.0.1:7878").await?;
|
||||||
/// socket.connect("127.0.0.1:8080").await?;
|
/// socket.connect("127.0.0.1:8080").await?;
|
||||||
|
/// let bytes = socket.send(b"Hi there!").await?;
|
||||||
///
|
///
|
||||||
/// let mut buf = vec![0; 1024];
|
/// println!("Sent {} bytes", bytes);
|
||||||
/// let n = socket.recv(&mut buf).await?;
|
|
||||||
/// println!("Received {} bytes", n);
|
|
||||||
/// #
|
/// #
|
||||||
/// # Ok(()) }) }
|
/// # Ok(()) }) }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
Loading…
Reference in a new issue