Merge pull request #1540 from RussHewgill/can_recv

Added can_recv for TcpSocket
This commit is contained in:
Dario Nieuwenhuis 2023-06-06 16:59:57 +00:00 committed by GitHub
commit 87ad66f2b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 its possible to receive data from the remote endpoint.
/// It will return true while there is data in the receive buffer, and if there isnt,
/// 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> {