Skip to content

Commit 476f380

Browse files
committed
Adding new TCP socket APIs
1 parent cb280e5 commit 476f380

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111
- Bump dependency version of `no-std-net` to `v0.6`.
1212
- Bump MSRV to 1.53.0 due to `no-std-net`'s use of or-patterns.
1313
- Added support for `core::net` with the `ip_in_core` feature.
14+
- [breaking] New APIs added to `TcpClientStack` to support more robust understanding of the TCP
15+
socket state
16+
* New APIs include `is_open()`, `may_send()`, and `may_recv()`
1417

1518
## [0.6.0] - 2021-05-25
1619

src/stack/tcp.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,21 @@ pub trait TcpClientStack {
2727
remote: SocketAddr,
2828
) -> nb::Result<(), Self::Error>;
2929

30-
/// Check if this socket is connected
31-
fn is_connected(&mut self, socket: &Self::TcpSocket) -> Result<bool, Self::Error>;
30+
/// Determine if a socket is opened.
31+
///
32+
/// Returns `Ok(true)` if the TCP socket is actively ingressing and egressing packets. This
33+
/// corresponds to any TCP state that is not `CLOSED` or `TIME-WAIT`.
34+
fn is_open(&mut self, socket: &Self::TcpSocket) -> Result<bool, Self::Error>;
35+
36+
/// Check if the TCP socket can transmit data.
37+
///
38+
/// Returns `Ok(true)` if the TCP transmit half is open and connected.
39+
fn may_send(&mut self, socket: &Self::TcpSocket) -> Result<bool, Self::Error>;
40+
41+
/// Check if the TCP socket can receive data.
42+
///
43+
/// Returns `Ok(true)` if the TCP receive half is open and connected.
44+
fn may_receive(&mut self, socket: &Self::TcpSocket) -> Result<bool, Self::Error>;
3245

3346
/// Write to the stream.
3447
///

0 commit comments

Comments
 (0)