about summary refs log tree commit diff
path: root/src/libstd/sys/common/net.rs
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2016-02-27 21:05:32 -0800
committerSteven Fackler <sfackler@gmail.com>2016-02-28 09:41:33 -0800
commit728d9115e894bd3c8fc3ae03230ea46f85467c04 (patch)
tree3e5867efbe40eb47af9655ba457137cb1d1f82a1 /src/libstd/sys/common/net.rs
parent5d6ba17f0308d3b8c96cd89f4c0663bae0f2b9f7 (diff)
downloadrust-728d9115e894bd3c8fc3ae03230ea46f85467c04.tar.gz
rust-728d9115e894bd3c8fc3ae03230ea46f85467c04.zip
Fix windows
Also back out keepalive support for TCP since the API is perhaps not
actually what we want. You can't read the interval on Windows, and
we should probably separate the functionality of turning keepalive on
and overriding the interval.
Diffstat (limited to 'src/libstd/sys/common/net.rs')
-rw-r--r--src/libstd/sys/common/net.rs23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs
index 31d3be45372..c8738fd1ba5 100644
--- a/src/libstd/sys/common/net.rs
+++ b/src/libstd/sys/common/net.rs
@@ -14,7 +14,7 @@ use cmp;
 use ffi::{CStr, CString};
 use fmt;
 use io::{self, Error, ErrorKind};
-use libc::{c_int, c_char, c_void};
+use libc::{c_int, c_char, c_void, c_uint};
 use mem;
 #[allow(deprecated)]
 use net::{SocketAddr, Shutdown, IpAddr, Ipv4Addr, Ipv6Addr};
@@ -84,13 +84,13 @@ fn sockaddr_to_addr(storage: &c::sockaddr_storage,
 }
 
 #[cfg(target_os = "android")]
-fn to_ipv6mr_interface(value: u32) -> c::c_int {
-    value as c::c_int
+fn to_ipv6mr_interface(value: u32) -> c_int {
+    value as c_int
 }
 
 #[cfg(not(target_os = "android"))]
-fn to_ipv6mr_interface(value: u32) -> c::c_uint {
-    value as c::c_uint
+fn to_ipv6mr_interface(value: u32) -> c_uint {
+    value as c_uint
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -239,20 +239,11 @@ impl TcpStream {
     }
 
     pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> {
-        setsockopt(&self.inner, c::IPPROTO_TCP, c::TCP_NODELAY, nodelay as c_int)
+        self.inner.set_nodelay(nodelay)
     }
 
     pub fn nodelay(&self) -> io::Result<bool> {
-        let raw: c_int = try!(getsockopt(&self.inner, c::IPPROTO_TCP, c::TCP_NODELAY));
-        Ok(raw != 0)
-    }
-
-    pub fn set_keepalive(&self, keepalive: Option<Duration>) -> io::Result<()> {
-        self.inner.set_keepalive(keepalive)
-    }
-
-    pub fn keepalive(&self) -> io::Result<Option<Duration>> {
-        self.inner.keepalive()
+        self.inner.nodelay()
     }
 
     pub fn set_ttl(&self, ttl: u32) -> io::Result<()> {