From 1a489d214d616af61b671cbb0ba3916638794169 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Tue, 30 Jan 2024 03:32:25 +0330 Subject: [PATCH 1/3] expose the set_keepalive method --- tokio/src/net/tcp/socket.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tokio/src/net/tcp/socket.rs b/tokio/src/net/tcp/socket.rs index 679e95866c5..007d445d0ee 100644 --- a/tokio/src/net/tcp/socket.rs +++ b/tokio/src/net/tcp/socket.rs @@ -185,6 +185,11 @@ impl TcpSocket { Ok(TcpSocket { inner }) } + /// Enable sending of keep-alive messages on connection-oriented sockets. + pub fn set_keepalive(&self, keepalive: bool) -> io::Result<()> { + self.inner.set_keepalive(keepalive) + } + /// Allows the socket to bind to an in-use address. /// /// Behavior is platform specific. Refer to the target platform's From d3b4bc998016f843e31ad608727b138203343b74 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Tue, 30 Jan 2024 03:37:35 +0330 Subject: [PATCH 2/3] update the doc --- tokio/src/net/tcp/socket.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/net/tcp/socket.rs b/tokio/src/net/tcp/socket.rs index 007d445d0ee..04f503f6d38 100644 --- a/tokio/src/net/tcp/socket.rs +++ b/tokio/src/net/tcp/socket.rs @@ -185,7 +185,7 @@ impl TcpSocket { Ok(TcpSocket { inner }) } - /// Enable sending of keep-alive messages on connection-oriented sockets. + /// Enable sending of keep-alive messages. pub fn set_keepalive(&self, keepalive: bool) -> io::Result<()> { self.inner.set_keepalive(keepalive) } From 21333f5e58031fa8c0ca783875f3345405afa2f4 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Tue, 30 Jan 2024 03:40:59 +0330 Subject: [PATCH 3/3] expose keepalive and update docs --- tokio/src/net/tcp/socket.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tokio/src/net/tcp/socket.rs b/tokio/src/net/tcp/socket.rs index 04f503f6d38..c528a14fe8e 100644 --- a/tokio/src/net/tcp/socket.rs +++ b/tokio/src/net/tcp/socket.rs @@ -185,11 +185,16 @@ impl TcpSocket { Ok(TcpSocket { inner }) } - /// Enable sending of keep-alive messages. + /// Sets value for the `SO_KEEPALIVE` option on this socket. pub fn set_keepalive(&self, keepalive: bool) -> io::Result<()> { self.inner.set_keepalive(keepalive) } + /// Gets the value of the `SO_KEEPALIVE` option on this socket. + pub fn keepalive(&self) -> io::Result { + self.inner.keepalive() + } + /// Allows the socket to bind to an in-use address. /// /// Behavior is platform specific. Refer to the target platform's