1
Fork 0

Fix MSG_CMSG_CLOEXEC for macos

This commit is contained in:
LinkTed 2020-09-22 13:17:12 +02:00
parent c2a1b50140
commit b01ce2cfd0

View file

@ -237,6 +237,15 @@ impl Socket {
self.recv_from_with_flags(buf, 0)
}
#[cfg(any(
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
pub fn recv_msg(&self, msg: &mut libc::msghdr) -> io::Result<usize> {
let n = cvt(unsafe { libc::recvmsg(self.0.raw(), msg, libc::MSG_CMSG_CLOEXEC) })?;
Ok(n as usize)
@ -259,6 +268,15 @@ impl Socket {
self.0.is_write_vectored()
}
#[cfg(any(
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
pub fn send_msg(&self, msg: &mut libc::msghdr) -> io::Result<usize> {
let n = cvt(unsafe { libc::sendmsg(self.0.raw(), msg, 0) })?;
Ok(n as usize)