aboutsummaryrefslogtreecommitdiff
path: root/embassy-net/src/udp.rs
diff options
context:
space:
mode:
authorFan Jiang <[email protected]>2024-10-20 12:29:38 -0400
committerDario Nieuwenhuis <[email protected]>2024-10-21 01:59:31 +0200
commitb4ee17fb4f1a77c26fc08e9fe9e0d343d1c059b4 (patch)
tree885de668949d20ea7f2d5471103f154108b4a223 /embassy-net/src/udp.rs
parentc9358e1f1e5d88aa0ad998c44eb2da6be73cf477 (diff)
net: Add flush for UDP and Raw sockets.
Diffstat (limited to 'embassy-net/src/udp.rs')
-rw-r--r--embassy-net/src/udp.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/embassy-net/src/udp.rs b/embassy-net/src/udp.rs
index 3eb6e2f83..ac650364e 100644
--- a/embassy-net/src/udp.rs
+++ b/embassy-net/src/udp.rs
@@ -241,6 +241,23 @@ impl<'a> UdpSocket<'a> {
241 .await 241 .await
242 } 242 }
243 243
244 /// Flush the socket.
245 ///
246 /// This method will wait until the socket is flushed.
247 pub async fn flush(&mut self) {
248 poll_fn(move |cx| {
249 self.with_mut(|s, _| {
250 if s.send_queue() == 0 {
251 Poll::Ready(())
252 } else {
253 s.register_send_waker(cx.waker());
254 Poll::Pending
255 }
256 })
257 })
258 .await
259 }
260
244 /// Returns the local endpoint of the socket. 261 /// Returns the local endpoint of the socket.
245 pub fn endpoint(&self) -> IpListenEndpoint { 262 pub fn endpoint(&self) -> IpListenEndpoint {
246 self.with(|s, _| s.endpoint()) 263 self.with(|s, _| s.endpoint())