tcp_stack: add keep-alive

This commit is contained in:
occheung 2020-09-25 17:07:29 +08:00
parent 6280e092e3
commit 242e03a8bd
1 changed files with 4 additions and 0 deletions

View File

@ -120,6 +120,8 @@ impl<'a, 'b, 'c, 'n> embedded_nal::TcpStack for NetworkStack<'a, 'b, 'c, 'n> {
internal_socket
.connect((address, remote.port()), self.get_ephemeral_port())
.map_err(|_| NetworkError::ConnectionFailure)?;
internal_socket
.set_keep_alive(Some(net::time::Duration::from_millis(1000)));
}
embedded_nal::IpAddr::V6(addr) => {
let address = {
@ -132,6 +134,8 @@ impl<'a, 'b, 'c, 'n> embedded_nal::TcpStack for NetworkStack<'a, 'b, 'c, 'n> {
internal_socket
.connect((address, remote.port()), self.get_ephemeral_port())
.map_err(|_| NetworkError::ConnectionFailure)?;
internal_socket
.set_keep_alive(Some(net::time::Duration::from_millis(1000)));
}
};