aboutsummaryrefslogtreecommitdiff
path: root/embassy-net/src
diff options
context:
space:
mode:
authorJuliDi <[email protected]>2023-09-10 20:13:56 +0200
committerJuliDi <[email protected]>2023-09-10 20:13:56 +0200
commitd6a1b567ee1eeaa98f9e8938227c0f3be3559670 (patch)
tree5f85a62cc2c50f86d1ef959d65052eb71cbd6331 /embassy-net/src
parenta47fb42962fffda51efbce072087c8ca2504a225 (diff)
add SocketNotBound error message
Diffstat (limited to 'embassy-net/src')
-rw-r--r--embassy-net/src/udp.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/embassy-net/src/udp.rs b/embassy-net/src/udp.rs
index 0a5a7b8f6..61058c1ba 100644
--- a/embassy-net/src/udp.rs
+++ b/embassy-net/src/udp.rs
@@ -29,6 +29,8 @@ pub enum BindError {
29pub enum Error { 29pub enum Error {
30 /// No route to host. 30 /// No route to host.
31 NoRoute, 31 NoRoute,
32 /// Socket not bound to an outgoing port.
33 SocketNotBound,
32} 34}
33 35
34/// An UDP socket. 36/// An UDP socket.
@@ -155,7 +157,14 @@ impl<'a> UdpSocket<'a> {
155 s.register_send_waker(cx.waker()); 157 s.register_send_waker(cx.waker());
156 Poll::Pending 158 Poll::Pending
157 } 159 }
158 Err(udp::SendError::Unaddressable) => Poll::Ready(Err(Error::NoRoute)), 160 Err(udp::SendError::Unaddressable) => {
161 // If no sender/outgoing port is specified, there is not really "no route"
162 if s.endpoint().port == 0 {
163 Poll::Ready(Err(Error::SocketNotBound))
164 } else {
165 Poll::Ready(Err(Error::NoRoute))
166 }
167 }
159 }) 168 })
160 } 169 }
161 170