add SocketNotBound error message

This commit is contained in:
JuliDi 2023-09-10 20:13:56 +02:00
parent a47fb42962
commit d6a1b567ee
No known key found for this signature in database
GPG Key ID: 0C98FD5D6597BC5B

View File

@ -29,6 +29,8 @@ pub enum BindError {
pub enum Error { pub enum Error {
/// No route to host. /// No route to host.
NoRoute, NoRoute,
/// Socket not bound to an outgoing port.
SocketNotBound,
} }
/// An UDP socket. /// An UDP socket.
@ -155,7 +157,14 @@ impl<'a> UdpSocket<'a> {
s.register_send_waker(cx.waker()); s.register_send_waker(cx.waker());
Poll::Pending Poll::Pending
} }
Err(udp::SendError::Unaddressable) => Poll::Ready(Err(Error::NoRoute)), Err(udp::SendError::Unaddressable) => {
// If no sender/outgoing port is specified, there is not really "no route"
if s.endpoint().port == 0 {
Poll::Ready(Err(Error::SocketNotBound))
} else {
Poll::Ready(Err(Error::NoRoute))
}
}
}) })
} }