tcp_stack: add keep-alive

This commit is contained in:
occheung 2020-09-25 17:07:29 +08:00
parent 6280e092e3
commit 242e03a8bd

View File

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