generated from tipragot/rust
Make an error when the connection is disconnected (#24)
All checks were successful
Rust Checks / checks (push) Successful in 8s
All checks were successful
Rust Checks / checks (push) Successful in 8s
Reviewed-on: corentin/border-wars#24 Reviewed-by: Corentin <solois.corentin@gmail.com> Co-authored-by: Tipragot <contact@tipragot.fr> Co-committed-by: Tipragot <contact@tipragot.fr>
This commit is contained in:
parent
2ca37c4ac0
commit
26e719eddc
|
@ -197,6 +197,12 @@ impl Connection {
|
|||
let receive_buffer = &mut self.receive_buffer[start_index..start_index + len];
|
||||
let received_len = self.stream.read(receive_buffer);
|
||||
self.receive_filled_len += match received_len {
|
||||
Ok(0) => {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::ConnectionAborted,
|
||||
"connection closed by remote peer",
|
||||
));
|
||||
}
|
||||
Ok(n) => n,
|
||||
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => return Ok(false),
|
||||
Err(ref e) if e.kind() == io::ErrorKind::Interrupted => return Ok(false),
|
||||
|
|
Loading…
Reference in a new issue