Trait UnixSocketExt

trait UnixSocketExt: Sealed

Linux-specific functionality for AF_UNIX sockets UnixDatagram and UnixStream.

Required Methods

fn passcred(self: &Self) -> Result<bool>

Query the current setting of socket option SO_PASSCRED.

fn set_passcred(self: &Self, passcred: bool) -> Result<()>

Enable or disable socket option SO_PASSCRED.

This option enables the credentials of the sending process to be received as a control message in AncillaryData.

Examples

#![feature(unix_socket_ancillary_data)]
#[cfg(target_os = "linux")]
use std::os::linux::net::UnixSocketExt;
#[cfg(target_os = "android")]
use std::os::android::net::UnixSocketExt;
use std::os::unix::net::UnixDatagram;

fn main() -> std::io::Result<()> {
    let sock = UnixDatagram::unbound()?;
    sock.set_passcred(true).expect("set_passcred failed");
    Ok(())
}

Implementors