Skip to content

Commit

Permalink
docs(embassy-net): Update can_send() and may_send() documentation to …
Browse files Browse the repository at this point in the history
…reflect actual behavior from smoltcp
  • Loading branch information
AnthonyGrondin committed Sep 24, 2024
1 parent b8cdffa commit 143be71
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion embassy-net/src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,25 @@ impl<'a> TcpSocket<'a> {
self.io.with_mut(|s, _| s.abort())
}

/// Get whether the socket is ready to send data, i.e. whether there is space in the send buffer.
/// Return whether the transmit half of the full-duplex connection is open.
///
/// This function returns true if it's possible to send data and have it arrive
/// to the remote endpoint. However, it does not make any guarantees about the state
/// of the transmit buffer, and even if it returns true, [write](#method.write) may
/// not be able to enqueue any octets.
///
/// In terms of the TCP state machine, the socket must be in the `ESTABLISHED` or
/// `CLOSE-WAIT` state.
pub fn may_send(&self) -> bool {
self.io.with(|s, _| s.may_send())
}

/// Check whether the transmit half of the full-duplex connection is open
/// (see [may_send](#method.may_send)), and the transmit buffer is not full.
pub fn can_send(&self) -> bool {
self.io.with(|s, _| s.can_send())
}

/// return whether the receive half of the full-duplex connection is open.
/// This function returns true if it’s possible to receive data from the remote endpoint.
/// It will return true while there is data in the receive buffer, and if there isn’t,
Expand Down

0 comments on commit 143be71

Please sign in to comment.