From 4d6e2f5334ea1b2455357e279e8606b69dd9cf4c Mon Sep 17 00:00:00 2001 From: Young Wu Date: Thu, 23 Apr 2015 10:27:44 +0800 Subject: [PATCH] implement set_tcp_keepalive for linux --- src/libstd/sys/common/net2.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libstd/sys/common/net2.rs b/src/libstd/sys/common/net2.rs index 7d42d65d360..2b2c31d92ed 100644 --- a/src/libstd/sys/common/net2.rs +++ b/src/libstd/sys/common/net2.rs @@ -202,15 +202,19 @@ impl TcpStream { setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_KEEPALIVE, seconds as c_int) } - #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] + #[cfg(any(target_os = "freebsd", + target_os = "dragonfly", + target_os = "linux"))] fn set_tcp_keepalive(&self, seconds: u32) -> io::Result<()> { setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_KEEPIDLE, seconds as c_int) } + #[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "freebsd", - target_os = "dragonfly")))] + target_os = "dragonfly", + target_os = "linux")))] fn set_tcp_keepalive(&self, _seconds: u32) -> io::Result<()> { Ok(()) }