aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-06-06 16:59:57 +0000
committerGitHub <[email protected]>2023-06-06 16:59:57 +0000
commit87ad66f2b4a5bfd36dfc8d8aad5492e9e3f915e6 (patch)
treeb2637072417ec8eb86e197076b809c98f62215fc
parenta9fdd468d56e8359b0bfd14a31462e5e38090e25 (diff)
parent2eb08b2dc92bc0393dc417de6ccdc039d30f6dd5 (diff)
Merge pull request #1540 from RussHewgill/can_recv
Added can_recv for TcpSocket
-rw-r--r--embassy-net/src/tcp.rs10
1 files changed, 9 insertions, 1 deletions
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> {
278 self.io.with(|s, _| s.may_send()) 278 self.io.with(|s, _| s.may_send())
279 } 279 }
280 280
281 /// Get whether the socket is ready to receive data, i.e. whether there is some pending data in the receive buffer. 281 /// return whether the recieve half of the full-duplex connection is open.
282 /// This function returns true if it’s possible to receive data from the remote endpoint.
283 /// It will return true while there is data in the receive buffer, and if there isn’t,
284 /// as long as the remote endpoint has not closed the connection.
282 pub fn may_recv(&self) -> bool { 285 pub fn may_recv(&self) -> bool {
283 self.io.with(|s, _| s.may_recv()) 286 self.io.with(|s, _| s.may_recv())
284 } 287 }
288
289 /// Get whether the socket is ready to receive data, i.e. whether there is some pending data in the receive buffer.
290 pub fn can_recv(&self) -> bool {
291 self.io.with(|s, _| s.can_recv())
292 }
285} 293}
286 294
287impl<'a> Drop for TcpSocket<'a> { 295impl<'a> Drop for TcpSocket<'a> {