Skip to content

Commit

Permalink
net: add UdpSocket readiness and non-blocking ops (#3138)
Browse files Browse the repository at this point in the history
Adds `ready()`, `readable()`, and `writable()` async methods for waiting
for socket readiness. Adds `try_send`, `try_send_to`, `try_recv`, and
`try_recv_from` for performing non-blocking operations on the socket.

This is the UDP equivalent of #3130.
  • Loading branch information
carllerche committed Nov 16, 2020
1 parent d0ebb41 commit 0ea2307
Show file tree
Hide file tree
Showing 3 changed files with 571 additions and 88 deletions.
5 changes: 2 additions & 3 deletions tokio/src/net/tcp/stream.rs
Expand Up @@ -385,7 +385,7 @@ impl TcpStream {
/// If data is successfully read, `Ok(n)` is returned, where `n` is the
/// number of bytes read. `Ok(n)` indicates the stream's read half is closed
/// and will no longer yield data. If the stream is not ready to read data
/// `Err(io::ErrorKinid::WouldBlock)` is returned.
/// `Err(io::ErrorKind::WouldBlock)` is returned.
///
/// # Examples
///
Expand Down Expand Up @@ -495,8 +495,7 @@ impl TcpStream {
/// The function will attempt to write the entire contents of `buf`, but
/// only part of the buffer may be written.
///
/// This function is equivalent to `ready(Interest::WRITABLE)` is usually
/// paired with `try_write()`.
/// This function is usually paired with `writable()`.
///
/// # Return
///
Expand Down

0 comments on commit 0ea2307

Please sign in to comment.