]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/sys/unix/net.rs
created tcpstream quickack trait
[rust.git] / library / std / src / sys / unix / net.rs
index a1bbc2d87b640919a89e6d5e4d41c3d2cf6318cb..85dcfc747afefefec017fca59ff21f3101a8088a 100644 (file)
@@ -139,8 +139,8 @@ pub fn new_pair(_fam: c_int, _ty: c_int) -> io::Result<(Socket, Socket)> {
     pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Result<()> {
         self.set_nonblocking(true)?;
         let r = unsafe {
-            let (addrp, len) = addr.into_inner();
-            cvt(libc::connect(self.as_raw_fd(), addrp, len))
+            let (addr, len) = addr.into_inner();
+            cvt(libc::connect(self.as_raw_fd(), addr.as_ptr(), len))
         };
         self.set_nonblocking(false)?;
 
@@ -392,6 +392,17 @@ pub fn nodelay(&self) -> io::Result<bool> {
         Ok(raw != 0)
     }
 
+    #[cfg(any(target_os = "android", target_os = "linux",))]
+    pub fn set_quickack(&self, quickack: bool) -> io::Result<()> {
+        setsockopt(self, libc::IPPROTO_TCP, libc::TCP_QUICKACK, quickack as c_int)
+    }
+
+    #[cfg(any(target_os = "android", target_os = "linux",))]
+    pub fn quickack(&self) -> io::Result<bool> {
+        let raw: c_int = getsockopt(self, libc::IPPROTO_TCP, libc::TCP_QUICKACK)?;
+        Ok(raw != 0)
+    }
+
     #[cfg(any(target_os = "android", target_os = "linux",))]
     pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
         setsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED, passcred as libc::c_int)