Skip to content

Commit 3efb49c

Browse files
committed
Address CR comments
Signed-off-by: Joe Grund <grundjoseph@gmail.com>
1 parent 2ddf30e commit 3efb49c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/host.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,17 @@ impl Udp {
277277

278278
Ok(UdpSocket::new(addr, rx))
279279
}
280-
pub(crate) fn connect(&mut self, src: SocketAddr, dst: SocketAddr) {
280+
pub(crate) fn connect(&mut self, src: SocketAddr, dst: SocketAddr) -> io::Result<()> {
281281
let Some(bind) = self.binds.get_mut(&src.port()) else {
282-
tracing::trace!(target: TRACING_TARGET, ?src, protocol = %"UDP", "Connect failed (no matching bind)");
283-
return;
282+
return Err(io::Error::new(
283+
io::ErrorKind::NotFound,
284+
"Connect failed (no matching bind) for {src}",
285+
));
284286
};
285287

286288
bind.target_addr = Some(dst);
289+
290+
Ok(())
287291
}
288292

289293
fn receive_from_network(&mut self, src: SocketAddr, dst: SocketAddr, datagram: Datagram) {

src/net/udp.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,8 @@ impl UdpSocket {
161161
let addr = addr.to_socket_addr(&world.dns);
162162
let host = world.current_host_mut();
163163

164-
host.udp.connect(self.local_addr, addr);
165-
});
166-
167-
Ok(())
164+
host.udp.connect(self.local_addr, addr)
165+
})
168166
}
169167

170168
/// This function will create a new UDP socket and attempt to bind it to

0 commit comments

Comments
 (0)