#[non_exhaustive]
pub enum SockAddr {
Inet(InetAddr),
Unix(UnixAddr),
Netlink(NetlinkAddr),
Alg(AlgAddr),
Link(LinkAddr),
Vsock(VsockAddr),
}
use SockaddrLike or SockaddrStorage instead
Expand description
Represents a socket address
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Inet(InetAddr)
use SockaddrLike or SockaddrStorage instead
Unix(UnixAddr)
use SockaddrLike or SockaddrStorage instead
Netlink(NetlinkAddr)
use SockaddrLike or SockaddrStorage instead
Alg(AlgAddr)
use SockaddrLike or SockaddrStorage instead
Link(LinkAddr)
use SockaddrLike or SockaddrStorage instead
Datalink address (MAC)
Vsock(VsockAddr)
use SockaddrLike or SockaddrStorage instead
Implementations
sourceimpl SockAddr
impl SockAddr
pub fn new_inet(addr: InetAddr) -> SockAddr
pub fn new_unix<P: ?Sized + NixPath>(path: &P) -> Result<SockAddr>
pub fn new_netlink(pid: u32, groups: u32) -> SockAddr
pub fn new_alg(alg_type: &str, alg_name: &str) -> SockAddr
pub fn new_vsock(cid: u32, port: u32) -> SockAddr
pub fn family(&self) -> AddressFamily
pub fn to_str(&self) -> String
use .to_string() instead
sourcepub fn as_ffi_pair(&self) -> (&sockaddr, socklen_t)
pub fn as_ffi_pair(&self) -> (&sockaddr, socklen_t)
Conversion from nix’s SockAddr type to the underlying libc sockaddr type.
This is useful for interfacing with other libc functions that don’t yet have nix wrappers. Returns a reference to the underlying data type (as a sockaddr reference) along with the size of the actual data type. sockaddr is commonly used as a proxy for a superclass as C doesn’t support inheritance, so many functions that take a sockaddr * need to take the size of the underlying type as well and then internally cast it back.