fix(sender): interpret all errors in confirmation recv as timeout
This commit is contained in:
parent
e22bf2c436
commit
4a1593801a
1 changed files with 4 additions and 10 deletions
|
@ -1,7 +1,4 @@
|
||||||
use std::{
|
use std::{io, net::UdpSocket};
|
||||||
io::{self, ErrorKind},
|
|
||||||
net::UdpSocket,
|
|
||||||
};
|
|
||||||
|
|
||||||
use image::{Rgb, RgbImage};
|
use image::{Rgb, RgbImage};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
@ -73,12 +70,9 @@ pub fn send_frame(
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut buf = vec![0; 100];
|
let mut buf = vec![0; 100];
|
||||||
let len = match socket.recv(&mut buf) {
|
let len = socket
|
||||||
Ok(len) => len,
|
.recv(&mut buf)
|
||||||
//Err(e) if e.kind() == ErrorKind::TimedOut => return Err(SenderError::ConfirmationTimeout),
|
.map_err(|_| SenderError::ConfirmationTimeout)?;
|
||||||
Err(e) => return Err(SenderError::ConfirmationTimeout),
|
|
||||||
Err(e) => return Err(SenderError::Io(e)),
|
|
||||||
};
|
|
||||||
let buf = &buf[..len];
|
let buf = &buf[..len];
|
||||||
let response_frame_num = u32::from_be_bytes(
|
let response_frame_num = u32::from_be_bytes(
|
||||||
buf.try_into()
|
buf.try_into()
|
||||||
|
|
Loading…
Reference in a new issue