1
Fork 0

Add set_passcred and passcred methods to UnixStream and UnixDatagram

This commit is contained in:
LinkTed 2020-09-07 18:00:01 +02:00
parent 19c5fdda7c
commit 686964f0f5
4 changed files with 131 additions and 11 deletions

View file

@ -323,6 +323,16 @@ impl Socket {
Ok(raw != 0)
}
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
let boolean: libc::c_int = if passcred { 1 } else { 0 };
setsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED, boolean)
}
pub fn passcred(&self) -> io::Result<bool> {
let passcred: libc::c_int = getsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED)?;
Ok(passcred != 0)
}
#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
let mut nonblocking = nonblocking as libc::c_int;