#[cfg(not(target_os = "linux"))]
const SOCK_CLOEXEC: c_int = 0;
-// Another conditional constant for name resolution: Macos et iOS use
-// SO_NOSIGPIPE as a setsockopt flag to disable SIGPIPE emission on socket.
-// Other platforms do otherwise.
-#[cfg(target_vendor = "apple")]
-use libc::SO_NOSIGPIPE;
-#[cfg(not(target_vendor = "apple"))]
-const SO_NOSIGPIPE: c_int = 0;
-
pub struct Socket(FileDesc);
pub fn init() {}
let fd = FileDesc::new(fd);
fd.set_cloexec()?;
let socket = Socket(fd);
- if cfg!(target_vendor = "apple") {
- setsockopt(&socket, libc::SOL_SOCKET, SO_NOSIGPIPE, 1)?;
- }
+
+ // macOS and iOS use `SO_NOSIGPIPE` as a `setsockopt`
+ // flag to disable `SIGPIPE` emission on socket.
+ #[cfg(target_vendor = "apple")]
+ setsockopt(&socket, libc::SOL_SOCKET, libc::SO_NOSIGPIPE, 1)?;
+
Ok(socket)
}
}