From 2eb08b2dc92bc0393dc417de6ccdc039d30f6dd5 Mon Sep 17 00:00:00 2001 From: Russ Hewgill Date: Tue, 6 Jun 2023 09:49:38 -0700 Subject: [PATCH] updated can_recv and may_recv to match the smoltcp functions. --- embassy-net/src/tcp.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index 7babb5293..515bbc5be 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs @@ -278,10 +278,18 @@ impl<'a> TcpSocket<'a> { self.io.with(|s, _| s.may_send()) } - /// Get whether the socket is ready to receive data, i.e. whether there is some pending data in the receive buffer. + /// return whether the recieve 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, + /// as long as the remote endpoint has not closed the connection. pub fn may_recv(&self) -> bool { self.io.with(|s, _| s.may_recv()) } + + /// Get whether the socket is ready to receive data, i.e. whether there is some pending data in the receive buffer. + pub fn can_recv(&self) -> bool { + self.io.with(|s, _| s.can_recv()) + } } impl<'a> Drop for TcpSocket<'a> {