diff --git a/library/std/src/sys/net/connection/socket/unix.rs b/library/std/src/sys/net/connection/socket/unix.rs index a191576d93b9d..561b24ade0696 100644 --- a/library/std/src/sys/net/connection/socket/unix.rs +++ b/library/std/src/sys/net/connection/socket/unix.rs @@ -362,11 +362,16 @@ impl Socket { } #[cfg(any(target_os = "android", target_os = "linux", target_os = "cygwin"))] - pub fn recv_msg(&self, msg: &mut libc::msghdr) -> io::Result { - let n = cvt(unsafe { libc::recvmsg(self.as_raw_fd(), msg, libc::MSG_CMSG_CLOEXEC) })?; + pub fn recv_msg_with_flags(&self, msg: &mut libc::msghdr, flags: c_int) -> io::Result { + let n = cvt(unsafe { libc::recvmsg(self.as_raw_fd(), msg, flags) })?; Ok(n as usize) } + #[cfg(any(target_os = "android", target_os = "linux", target_os = "cygwin"))] + pub fn recv_msg(&self, msg: &mut libc::msghdr) -> io::Result { + self.recv_msg_with_flags(msg, libc::MSG_CMSG_CLOEXEC) + } + pub fn peek_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { self.recv_from_with_flags(buf, MSG_PEEK) } @@ -385,11 +390,16 @@ impl Socket { } #[cfg(any(target_os = "android", target_os = "linux", target_os = "cygwin"))] - pub fn send_msg(&self, msg: &mut libc::msghdr) -> io::Result { - let n = cvt(unsafe { libc::sendmsg(self.as_raw_fd(), msg, 0) })?; + pub fn send_msg_with_flags(&self, msg: &libc::msghdr, flags: c_int) -> io::Result { + let n = cvt(unsafe { libc::sendmsg(self.as_raw_fd(), msg, flags) })?; Ok(n as usize) } + #[cfg(any(target_os = "android", target_os = "linux", target_os = "cygwin"))] + pub fn send_msg(&self, msg: &libc::msghdr) -> io::Result { + self.send_msg_with_flags(msg, 0) + } + pub fn set_timeout(&self, dur: Option, kind: libc::c_int) -> io::Result<()> { let timeout = match dur { Some(dur) => {