From 242e03a8bdba8639ed4d3ff4cdfbc28a2d8c27a1 Mon Sep 17 00:00:00 2001 From: occheung Date: Fri, 25 Sep 2020 17:07:29 +0800 Subject: [PATCH] tcp_stack: add keep-alive --- src/nal_tcp_client.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nal_tcp_client.rs b/src/nal_tcp_client.rs index 314a60c..5d3627b 100644 --- a/src/nal_tcp_client.rs +++ b/src/nal_tcp_client.rs @@ -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))); } };